Revision: 13373
Author:   da...@chromium.org
Date:     Mon Jan 14 06:11:06 2013
Log:      Merged r13230, r13258 into 3.15 branch.

MIPS: Improve array to string conversion.

MIPS: ARM: fix a bug with saving lr register in GenerateSmiToDouble.

R=mstarzin...@chromium.org

Review URL: https://chromiumcodereview.appspot.com/11878019
http://code.google.com/p/v8/source/detail?r=13373

Modified:
 /branches/3.15/src/mips/codegen-mips.cc
 /branches/3.15/src/mips/full-codegen-mips.cc
 /branches/3.15/src/mips/lithium-codegen-mips.cc
 /branches/3.15/src/mips/lithium-mips.cc
 /branches/3.15/src/mips/lithium-mips.h
 /branches/3.15/src/version.cc

=======================================
--- /branches/3.15/src/mips/codegen-mips.cc     Fri Nov 30 02:13:25 2012
+++ /branches/3.15/src/mips/codegen-mips.cc     Mon Jan 14 06:11:06 2013
@@ -246,7 +246,7 @@
                       HeapObject::kMapOffset,
                       a3,
                       t5,
-                      kRAHasBeenSaved,
+                      kRAHasNotBeenSaved,
                       kDontSaveFPRegs,
                       OMIT_REMEMBERED_SET,
                       OMIT_SMI_CHECK);
@@ -515,6 +515,50 @@
   __ lbu(result, MemOperand(at));
   __ bind(&done);
 }
+
+
+void SeqStringSetCharGenerator::Generate(MacroAssembler* masm,
+                                         String::Encoding encoding,
+                                         Register string,
+                                         Register index,
+                                         Register value) {
+  if (FLAG_debug_code) {
+    __ And(at, index, Operand(kSmiTagMask));
+    __ Check(eq, "Non-smi index", at, Operand(zero_reg));
+    __ And(at, value, Operand(kSmiTagMask));
+    __ Check(eq, "Non-smi value", at, Operand(zero_reg));
+
+    __ lw(at, FieldMemOperand(string, String::kLengthOffset));
+    __ Check(lt, "Index is too large", at, Operand(index));
+
+    __ Check(ge, "Index is negative", index, Operand(Smi::FromInt(0)));
+
+    __ lw(at, FieldMemOperand(string, HeapObject::kMapOffset));
+    __ lbu(at, FieldMemOperand(at, Map::kInstanceTypeOffset));
+
+ __ And(at, at, Operand(kStringRepresentationMask | kStringEncodingMask)); + static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; + static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag;
+    __ Check(eq, "Unexpected string type", at,
+        Operand(encoding == String::ONE_BYTE_ENCODING
+                    ? one_byte_seq_type : two_byte_seq_type));
+  }
+
+  __ Addu(at,
+          string,
+          Operand(SeqString::kHeaderSize - kHeapObjectTag));
+  __ SmiUntag(value);
+  STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0);
+  if (encoding == String::ONE_BYTE_ENCODING) {
+    __ SmiUntag(index);
+    __ Addu(at, at, index);
+    __ sb(value, MemOperand(at));
+  } else {
+    // No need to untag a smi for two-byte addressing.
+    __ Addu(at, at, index);
+    __ sh(value, MemOperand(at));
+  }
+}


 static MemOperand ExpConstant(int index, Register base) {
=======================================
--- /branches/3.15/src/mips/full-codegen-mips.cc        Fri Dec  7 04:40:13 2012
+++ /branches/3.15/src/mips/full-codegen-mips.cc        Mon Jan 14 06:11:06 2013
@@ -3144,6 +3144,38 @@
   __ bind(&done);
   context()->Plug(v0);
 }
+
+
+void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) {
+  ZoneList<Expression*>* args = expr->arguments();
+  ASSERT_EQ(3, args->length());
+
+  VisitForStackValue(args->at(1));  // index
+  VisitForStackValue(args->at(2));  // value
+  __ pop(a2);
+  __ pop(a1);
+  VisitForAccumulatorValue(args->at(0));  // string
+
+  static const String::Encoding encoding = String::ONE_BYTE_ENCODING;
+  SeqStringSetCharGenerator::Generate(masm_, encoding, v0, a1, a2);
+  context()->Plug(v0);
+}
+
+
+void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) {
+  ZoneList<Expression*>* args = expr->arguments();
+  ASSERT_EQ(3, args->length());
+
+  VisitForStackValue(args->at(1));  // index
+  VisitForStackValue(args->at(2));  // value
+  __ pop(a2);
+  __ pop(a1);
+  VisitForAccumulatorValue(args->at(0));  // string
+
+  static const String::Encoding encoding = String::TWO_BYTE_ENCODING;
+  SeqStringSetCharGenerator::Generate(masm_, encoding, v0, a1, a2);
+  context()->Plug(v0);
+}


 void FullCodeGenerator::EmitMathPow(CallRuntime* expr) {
=======================================
--- /branches/3.15/src/mips/lithium-codegen-mips.cc     Fri Nov 30 02:13:25 2012
+++ /branches/3.15/src/mips/lithium-codegen-mips.cc     Mon Jan 14 06:11:06 2013
@@ -1387,6 +1387,15 @@
     __ bind(&done);
   }
 }
+
+
+void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) {
+  SeqStringSetCharGenerator::Generate(masm(),
+                                      instr->encoding(),
+                                      ToRegister(instr->string()),
+                                      ToRegister(instr->index()),
+                                      ToRegister(instr->value()));
+}


 void LCodeGen::DoBitNotI(LBitNotI* instr) {
=======================================
--- /branches/3.15/src/mips/lithium-mips.cc     Fri Nov 30 02:13:25 2012
+++ /branches/3.15/src/mips/lithium-mips.cc     Mon Jan 14 06:11:06 2013
@@ -1529,6 +1529,16 @@
       new(zone()) LDateField(object, FixedTemp(a1), instr->index());
return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY);
 }
+
+
+LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) {
+  LOperand* string = UseRegister(instr->string());
+  LOperand* index = UseRegister(instr->index());
+  LOperand* value = UseRegister(instr->value());
+  LSeqStringSetChar* result =
+ new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value);
+  return DefineAsRegister(result);
+}


 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
=======================================
--- /branches/3.15/src/mips/lithium-mips.h      Fri Nov 30 02:13:25 2012
+++ /branches/3.15/src/mips/lithium-mips.h      Mon Jan 14 06:11:06 2013
@@ -148,6 +148,7 @@
   V(Random)                                     \
   V(RegExpLiteral)                              \
   V(Return)                                     \
+  V(SeqStringSetChar)                           \
   V(ShiftI)                                     \
   V(SmiTag)                                     \
   V(SmiUntag)                                   \
@@ -1143,6 +1144,30 @@
 };


+class LSeqStringSetChar: public LTemplateInstruction<1, 3, 0> {
+ public:
+  LSeqStringSetChar(String::Encoding encoding,
+                    LOperand* string,
+                    LOperand* index,
+                    LOperand* value) : encoding_(encoding) {
+    inputs_[0] = string;
+    inputs_[1] = index;
+    inputs_[2] = value;
+  }
+
+  String::Encoding encoding() { return encoding_; }
+  LOperand* string() { return inputs_[0]; }
+  LOperand* index() { return inputs_[1]; }
+  LOperand* value() { return inputs_[2]; }
+
+  DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar, "seq-string-set-char")
+  DECLARE_HYDROGEN_ACCESSOR(SeqStringSetChar)
+
+ private:
+  String::Encoding encoding_;
+};
+
+
 class LThrow: public LTemplateInstruction<0, 1, 0> {
  public:
   explicit LThrow(LOperand* value) {
=======================================
--- /branches/3.15/src/version.cc       Fri Jan 11 00:07:08 2013
+++ /branches/3.15/src/version.cc       Mon Jan 14 06:11:06 2013
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     15
 #define BUILD_NUMBER      11
-#define PATCH_LEVEL       7
+#define PATCH_LEVEL       8
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
 #define IS_CANDIDATE_VERSION 0

--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev

Reply via email to