Commit c00dcbe5 authored by whesse@chromium.org's avatar whesse@chromium.org

Fix error introduced in version 3820. Add optimization suggested by the error.

Review URL: http://codereview.chromium.org/597006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3823 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9b5c312b
......@@ -189,8 +189,9 @@ void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm,
}
// Generate code to check if an object is a string. If the object is
// a string, the map's instance type is left in the scratch1 register.
// Generate code to check if an object is a string. If the object is a
// heap object, its map's instance type is left in the scratch1 register.
// If this is not needed, scratch1 and scratch2 may be the same register.
static void GenerateStringCheck(MacroAssembler* masm,
Register receiver,
Register scratch1,
......@@ -220,13 +221,11 @@ void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm,
Register scratch1,
Register scratch2,
Label* miss) {
Label check_string, check_wrapper;
Label check_wrapper;
__ bind(&check_string);
// Check if the object is a string leaving the instance type in the
// scratch1 register.
GenerateStringCheck(masm, receiver, scratch1, scratch2,
miss, &check_wrapper);
GenerateStringCheck(masm, receiver, scratch1, scratch2, miss, &check_wrapper);
// Load length directly from the string.
__ ldr(r0, FieldMemOperand(receiver, String::kLengthOffset));
......@@ -238,9 +237,12 @@ void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm,
__ cmp(scratch1, Operand(JS_VALUE_TYPE));
__ b(ne, miss);
// Unwrap the value in place and check if the wrapped value is a string.
__ ldr(receiver, FieldMemOperand(receiver, JSValue::kValueOffset));
__ b(&check_string);
// Unwrap the value and check if the wrapped value is a string.
__ ldr(scratch1, FieldMemOperand(receiver, JSValue::kValueOffset));
GenerateStringCheck(masm, scratch1, scratch2, scratch2, miss, miss);
__ ldr(r0, FieldMemOperand(scratch1, String::kLengthOffset));
__ mov(r0, Operand(r0, LSL, kSmiTagSize));
__ Ret();
}
......
......@@ -229,14 +229,13 @@ void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm,
Register scratch1,
Register scratch2,
Label* miss) {
Label load_length, check_wrapper;
Label check_wrapper;
// Check if the object is a string leaving the instance type in the
// scratch register.
GenerateStringCheck(masm, receiver, scratch1, miss, &check_wrapper);
// Load length from the string and convert to a smi.
__ bind(&load_length);
__ mov(eax, FieldOperand(receiver, String::kLengthOffset));
__ SmiTag(eax);
__ ret(0);
......@@ -250,7 +249,9 @@ void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm,
// directly if it is.
__ mov(scratch2, FieldOperand(receiver, JSValue::kValueOffset));
GenerateStringCheck(masm, scratch2, scratch1, miss, miss);
__ jmp(&load_length);
__ mov(eax, FieldOperand(scratch2, String::kLengthOffset));
__ SmiTag(eax);
__ ret(0);
}
......
......@@ -346,6 +346,7 @@ class StubCompiler BASE_EMBEDDED {
static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm,
int index,
Register prototype);
static void GenerateFastPropertyLoad(MacroAssembler* masm,
Register dst, Register src,
JSObject* holder, int index);
......@@ -354,16 +355,19 @@ class StubCompiler BASE_EMBEDDED {
Register receiver,
Register scratch,
Label* miss_label);
static void GenerateLoadStringLength(MacroAssembler* masm,
Register receiver,
Register scratch1,
Register scratch2,
Label* miss_label);
static void GenerateLoadFunctionPrototype(MacroAssembler* masm,
Register receiver,
Register scratch1,
Register scratch2,
Label* miss_label);
static void GenerateStoreField(MacroAssembler* masm,
Builtins::Name storage_extend,
JSObject* object,
......@@ -373,6 +377,7 @@ class StubCompiler BASE_EMBEDDED {
Register name_reg,
Register scratch,
Label* miss_label);
static void GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind);
// Check the integrity of the prototype chain to make sure that the
......
......@@ -317,14 +317,13 @@ void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm,
Register scratch1,
Register scratch2,
Label* miss) {
Label load_length, check_wrapper;
Label check_wrapper;
// Check if the object is a string leaving the instance type in the
// scratch register.
GenerateStringCheck(masm, receiver, scratch1, miss, &check_wrapper);
// Load length directly from the string.
__ bind(&load_length);
__ movl(rax, FieldOperand(receiver, String::kLengthOffset));
__ Integer32ToSmi(rax, rax);
__ ret(0);
......@@ -338,8 +337,9 @@ void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm,
// directly if it is.
__ movq(scratch2, FieldOperand(receiver, JSValue::kValueOffset));
GenerateStringCheck(masm, scratch2, scratch1, miss, miss);
__ movq(receiver, scratch2);
__ jmp(&load_length);
__ movl(rax, FieldOperand(scratch2, String::kLengthOffset));
__ Integer32ToSmi(rax, rax);
__ ret(0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment