Revision: 16679
Author: [email protected]
Date: Thu Sep 12 11:15:12 2013 UTC
Log: Revert "Clean up after r16292 (disable optimization for
StringWrappers)."
[email protected]
BUG=
Review URL: https://codereview.chromium.org/23600040
http://code.google.com/p/v8/source/detail?r=16679
Modified:
/branches/bleeding_edge/src/arm/code-stubs-arm.cc
/branches/bleeding_edge/src/arm/full-codegen-arm.cc
/branches/bleeding_edge/src/ia32/code-stubs-ia32.cc
/branches/bleeding_edge/src/ia32/full-codegen-ia32.cc
/branches/bleeding_edge/src/mips/code-stubs-mips.cc
/branches/bleeding_edge/src/mips/full-codegen-mips.cc
/branches/bleeding_edge/src/x64/code-stubs-x64.cc
/branches/bleeding_edge/src/x64/full-codegen-x64.cc
/branches/bleeding_edge/test/mjsunit/regress/regress-2855.js
=======================================
--- /branches/bleeding_edge/src/arm/code-stubs-arm.cc Thu Sep 12 10:55:57
2013 UTC
+++ /branches/bleeding_edge/src/arm/code-stubs-arm.cc Thu Sep 12 11:15:12
2013 UTC
@@ -5790,6 +5790,7 @@
__ b(lt, &done);
// Check the number to string cache.
+ Label not_cached;
__ bind(¬_string);
// Puts the cached result into scratch1.
NumberToStringStub::GenerateLookupNumberStringCache(masm,
@@ -5798,9 +5799,26 @@
scratch2,
scratch3,
scratch4,
- slow);
+ ¬_cached);
__ mov(arg, scratch1);
__ str(arg, MemOperand(sp, stack_offset));
+ __ jmp(&done);
+
+ // Check if the argument is a safe string wrapper.
+ __ bind(¬_cached);
+ __ JumpIfSmi(arg, slow);
+ __ CompareObjectType(
+ arg, scratch1, scratch2, JS_VALUE_TYPE); // map -> scratch1.
+ __ b(ne, slow);
+ __ ldrb(scratch2, FieldMemOperand(scratch1, Map::kBitField2Offset));
+ __ and_(scratch2,
+ scratch2, Operand(1 <<
Map::kStringWrapperSafeForDefaultValueOf));
+ __ cmp(scratch2,
+ Operand(1 << Map::kStringWrapperSafeForDefaultValueOf));
+ __ b(ne, slow);
+ __ ldr(arg, FieldMemOperand(arg, JSValue::kValueOffset));
+ __ str(arg, MemOperand(sp, stack_offset));
+
__ bind(&done);
}
=======================================
--- /branches/bleeding_edge/src/arm/full-codegen-arm.cc Thu Sep 12 10:55:57
2013 UTC
+++ /branches/bleeding_edge/src/arm/full-codegen-arm.cc Thu Sep 12 11:15:12
2013 UTC
@@ -3007,7 +3007,7 @@
VisitForAccumulatorValue(args->at(0));
- Label materialize_true, materialize_false, skip_lookup;
+ Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
@@ -3019,7 +3019,7 @@
__ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset));
__ ldrb(ip, FieldMemOperand(r1, Map::kBitField2Offset));
__ tst(ip, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf));
- __ b(ne, &skip_lookup);
+ __ b(ne, if_true);
// Check for fast case object. Generate false result for slow case
object.
__ ldr(r2, FieldMemOperand(r0, JSObject::kPropertiesOffset));
@@ -3065,14 +3065,6 @@
__ b(ne, &loop);
__ bind(&done);
-
- // Set the bit in the map to indicate that there is no local valueOf
field.
- __ ldrb(r2, FieldMemOperand(r1, Map::kBitField2Offset));
- __ orr(r2, r2, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf));
- __ strb(r2, FieldMemOperand(r1, Map::kBitField2Offset));
-
- __ bind(&skip_lookup);
-
// If a valueOf property is not found on the object check that its
// prototype is the un-modified String prototype. If not result is false.
__ ldr(r2, FieldMemOperand(r1, Map::kPrototypeOffset));
@@ -3082,9 +3074,11 @@
__ ldr(r3, FieldMemOperand(r3, GlobalObject::kNativeContextOffset));
__ ldr(r3, ContextOperand(r3,
Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX));
__ cmp(r2, r3);
+ __ b(ne, if_false);
+
+ __ jmp(if_true);
+
PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
- Split(eq, if_true, if_false, fall_through);
-
context()->Plug(if_true, if_false);
}
=======================================
--- /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Thu Sep 12 10:55:57
2013 UTC
+++ /branches/bleeding_edge/src/ia32/code-stubs-ia32.cc Thu Sep 12 11:15:12
2013 UTC
@@ -5515,6 +5515,7 @@
__ j(below, &done);
// Check the number to string cache.
+ Label not_cached;
__ bind(¬_string);
// Puts the cached result into scratch1.
NumberToStringStub::GenerateLookupNumberStringCache(masm,
@@ -5522,9 +5523,22 @@
scratch1,
scratch2,
scratch3,
- slow);
+ ¬_cached);
__ mov(arg, scratch1);
__ mov(Operand(esp, stack_offset), arg);
+ __ jmp(&done);
+
+ // Check if the argument is a safe string wrapper.
+ __ bind(¬_cached);
+ __ JumpIfSmi(arg, slow);
+ __ CmpObjectType(arg, JS_VALUE_TYPE, scratch1); // map -> scratch1.
+ __ j(not_equal, slow);
+ __ test_b(FieldOperand(scratch1, Map::kBitField2Offset),
+ 1 << Map::kStringWrapperSafeForDefaultValueOf);
+ __ j(zero, slow);
+ __ mov(arg, FieldOperand(arg, JSValue::kValueOffset));
+ __ mov(Operand(esp, stack_offset), arg);
+
__ bind(&done);
}
=======================================
--- /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Thu Sep 12
10:55:57 2013 UTC
+++ /branches/bleeding_edge/src/ia32/full-codegen-ia32.cc Thu Sep 12
11:15:12 2013 UTC
@@ -2956,7 +2956,7 @@
VisitForAccumulatorValue(args->at(0));
- Label materialize_true, materialize_false, skip_lookup;
+ Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
@@ -2970,7 +2970,7 @@
__ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
__ test_b(FieldOperand(ebx, Map::kBitField2Offset),
1 << Map::kStringWrapperSafeForDefaultValueOf);
- __ j(not_zero, &skip_lookup);
+ __ j(not_zero, if_true);
// Check for fast case object. Return false for slow case objects.
__ mov(ecx, FieldOperand(eax, JSObject::kPropertiesOffset));
@@ -3013,15 +3013,9 @@
__ bind(&done);
- // Set the bit in the map to indicate that there is no local valueOf
field.
- __ or_(FieldOperand(ebx, Map::kBitField2Offset),
- Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf));
-
// Reload map as register ebx was used as temporary above.
__ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
- __ bind(&skip_lookup);
-
// If a valueOf property is not found on the object check that its
// prototype is the un-modified String prototype. If not result is false.
__ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset));
@@ -3033,9 +3027,10 @@
__ cmp(ecx,
ContextOperand(edx,
Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX));
+ __ j(not_equal, if_false);
+ __ jmp(if_true);
+
PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
- Split(equal, if_true, if_false, fall_through);
-
context()->Plug(if_true, if_false);
}
=======================================
--- /branches/bleeding_edge/src/mips/code-stubs-mips.cc Thu Sep 12 10:55:57
2013 UTC
+++ /branches/bleeding_edge/src/mips/code-stubs-mips.cc Thu Sep 12 11:15:12
2013 UTC
@@ -5861,6 +5861,7 @@
__ Branch(&done, lt, scratch1, Operand(FIRST_NONSTRING_TYPE));
// Check the number to string cache.
+ Label not_cached;
__ bind(¬_string);
// Puts the cached result into scratch1.
NumberToStringStub::GenerateLookupNumberStringCache(masm,
@@ -5869,9 +5870,23 @@
scratch2,
scratch3,
scratch4,
- slow);
+ ¬_cached);
__ mov(arg, scratch1);
__ sw(arg, MemOperand(sp, stack_offset));
+ __ jmp(&done);
+
+ // Check if the argument is a safe string wrapper.
+ __ bind(¬_cached);
+ __ JumpIfSmi(arg, slow);
+ __ GetObjectType(arg, scratch1, scratch2); // map -> scratch1.
+ __ Branch(slow, ne, scratch2, Operand(JS_VALUE_TYPE));
+ __ lbu(scratch2, FieldMemOperand(scratch1, Map::kBitField2Offset));
+ __ li(scratch4, 1 << Map::kStringWrapperSafeForDefaultValueOf);
+ __ And(scratch2, scratch2, scratch4);
+ __ Branch(slow, ne, scratch2, Operand(scratch4));
+ __ lw(arg, FieldMemOperand(arg, JSValue::kValueOffset));
+ __ sw(arg, MemOperand(sp, stack_offset));
+
__ bind(&done);
}
=======================================
--- /branches/bleeding_edge/src/mips/full-codegen-mips.cc Thu Sep 12
10:55:57 2013 UTC
+++ /branches/bleeding_edge/src/mips/full-codegen-mips.cc Thu Sep 12
11:15:12 2013 UTC
@@ -3028,7 +3028,7 @@
VisitForAccumulatorValue(args->at(0));
- Label materialize_true, materialize_false, skip_lookup;
+ Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
@@ -3040,7 +3040,7 @@
__ lw(a1, FieldMemOperand(v0, HeapObject::kMapOffset));
__ lbu(t0, FieldMemOperand(a1, Map::kBitField2Offset));
__ And(t0, t0, 1 << Map::kStringWrapperSafeForDefaultValueOf);
- __ Branch(&skip_lookup, ne, t0, Operand(zero_reg));
+ __ Branch(if_true, ne, t0, Operand(zero_reg));
// Check for fast case object. Generate false result for slow case
object.
__ lw(a2, FieldMemOperand(v0, JSObject::kPropertiesOffset));
@@ -3086,14 +3086,6 @@
__ Branch(&loop, ne, t0, Operand(a2));
__ bind(&done);
-
- // Set the bit in the map to indicate that there is no local valueOf
field.
- __ lbu(a2, FieldMemOperand(a1, Map::kBitField2Offset));
- __ Or(a2, a2, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf));
- __ sb(a2, FieldMemOperand(a1, Map::kBitField2Offset));
-
- __ bind(&skip_lookup);
-
// If a valueOf property is not found on the object check that its
// prototype is the un-modified String prototype. If not result is false.
__ lw(a2, FieldMemOperand(a1, Map::kPrototypeOffset));
@@ -3102,9 +3094,11 @@
__ lw(a3, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX));
__ lw(a3, FieldMemOperand(a3, GlobalObject::kNativeContextOffset));
__ lw(a3, ContextOperand(a3,
Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX));
+ __ Branch(if_false, ne, a2, Operand(a3));
+
+ __ jmp(if_true);
+
PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
- Split(eq, a2, Operand(a3), if_true, if_false, fall_through);
-
context()->Plug(if_true, if_false);
}
=======================================
--- /branches/bleeding_edge/src/x64/code-stubs-x64.cc Thu Sep 12 10:55:57
2013 UTC
+++ /branches/bleeding_edge/src/x64/code-stubs-x64.cc Thu Sep 12 11:15:12
2013 UTC
@@ -4644,6 +4644,7 @@
__ j(below, &done);
// Check the number to string cache.
+ Label not_cached;
__ bind(¬_string);
// Puts the cached result into scratch1.
NumberToStringStub::GenerateLookupNumberStringCache(masm,
@@ -4651,9 +4652,22 @@
scratch1,
scratch2,
scratch3,
- slow);
+ ¬_cached);
__ movq(arg, scratch1);
__ movq(Operand(rsp, stack_offset), arg);
+ __ jmp(&done);
+
+ // Check if the argument is a safe string wrapper.
+ __ bind(¬_cached);
+ __ JumpIfSmi(arg, slow);
+ __ CmpObjectType(arg, JS_VALUE_TYPE, scratch1); // map -> scratch1.
+ __ j(not_equal, slow);
+ __ testb(FieldOperand(scratch1, Map::kBitField2Offset),
+ Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf));
+ __ j(zero, slow);
+ __ movq(arg, FieldOperand(arg, JSValue::kValueOffset));
+ __ movq(Operand(rsp, stack_offset), arg);
+
__ bind(&done);
}
=======================================
--- /branches/bleeding_edge/src/x64/full-codegen-x64.cc Thu Sep 12 10:55:57
2013 UTC
+++ /branches/bleeding_edge/src/x64/full-codegen-x64.cc Thu Sep 12 11:15:12
2013 UTC
@@ -2935,7 +2935,7 @@
VisitForAccumulatorValue(args->at(0));
- Label materialize_true, materialize_false, skip_lookup;
+ Label materialize_true, materialize_false;
Label* if_true = NULL;
Label* if_false = NULL;
Label* fall_through = NULL;
@@ -2949,7 +2949,7 @@
__ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
__ testb(FieldOperand(rbx, Map::kBitField2Offset),
Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf));
- __ j(not_zero, &skip_lookup);
+ __ j(not_zero, if_true);
// Check for fast case object. Generate false result for slow case
object.
__ movq(rcx, FieldOperand(rax, JSObject::kPropertiesOffset));
@@ -2991,16 +2991,9 @@
__ j(not_equal, &loop);
__ bind(&done);
-
- // Set the bit in the map to indicate that there is no local valueOf
field.
- __ or_(FieldOperand(rbx, Map::kBitField2Offset),
- Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf));
-
// Reload map as register rbx was used as temporary above.
__ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset));
- __ bind(&skip_lookup);
-
// If a valueOf property is not found on the object check that its
// prototype is the un-modified String prototype. If not result is false.
__ movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset));
@@ -3011,9 +3004,10 @@
__ movq(rdx, FieldOperand(rdx, GlobalObject::kNativeContextOffset));
__ cmpq(rcx,
ContextOperand(rdx,
Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX));
+ __ j(not_equal, if_false);
+ __ jmp(if_true);
+
PrepareForBailoutBeforeSplit(expr, true, if_true, if_false);
- Split(equal, if_true, if_false, fall_through);
-
context()->Plug(if_true, if_false);
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/regress/regress-2855.js Thu Sep 12
10:55:57 2013 UTC
+++ /branches/bleeding_edge/test/mjsunit/regress/regress-2855.js Thu Sep 12
11:15:12 2013 UTC
@@ -39,19 +39,3 @@
}
assertEquals(expected, "" + foo("hello"));
}
-
-// Make sure we look up "valueOf" only once.
-var count = 0;
-var x = new String("foo");
-Object.defineProperty(x, "valueOf",
- { get: function() {
- count++;
- return function() {
- return 11;
- }
- }
- });
-for (var i = 0; i < 3; i++) {
- assertEquals("11", "" + x);
- assertEquals(i + 1, count);
-}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.