Reviewers: Mads Ager,
Description:
Merge t6773 to 3.0 branch.
Please review this at http://codereview.chromium.org/6515013/
SVN Base: http://v8.googlecode.com/svn/branches/3.0/
Affected files:
M src/arm/ic-arm.cc
M src/arm/macro-assembler-arm.h
M src/arm/macro-assembler-arm.cc
M src/ia32/ic-ia32.cc
M src/x64/ic-x64.cc
M src/x64/macro-assembler-x64.h
M src/x64/macro-assembler-x64.cc
A + test/mjsunit/regress/regress-1146.js
### BEGIN SVN COPY METADATA
#$ cp branches/bleeding_edge/test/mjsunit/regress/regress-1146.js
test/mjsunit/regress/regress-1146.js
### END SVN COPY METADATA
Index: src/arm/ic-arm.cc
===================================================================
--- src/arm/ic-arm.cc (revision 6774)
+++ src/arm/ic-arm.cc (working copy)
@@ -115,6 +115,9 @@
Register name,
Register scratch1,
Register scratch2) {
+ // Assert that name contains a string.
+ if (FLAG_debug_code) __ AbortIfNotString(name);
+
// Compute the capacity mask.
const int kCapacityOffset = StringDictionary::kHeaderSize +
StringDictionary::kCapacityIndex * kPointerSize;
@@ -843,7 +846,14 @@
// -- lr : return address
// -----------------------------------
+ // Check if the name is a string.
+ Label miss;
+ __ tst(r2, Operand(kSmiTagMask));
+ __ b(eq, &miss);
+ __ IsObjectJSStringType(r2, r0, &miss);
+
GenerateCallNormal(masm, argc);
+ __ bind(&miss);
GenerateMiss(masm, argc);
}
Index: src/arm/macro-assembler-arm.cc
===================================================================
--- src/arm/macro-assembler-arm.cc (revision 6774)
+++ src/arm/macro-assembler-arm.cc (working copy)
@@ -919,8 +919,8 @@
void MacroAssembler::IsObjectJSStringType(Register object,
- Register scratch,
- Label* fail) {
+ Register scratch,
+ Label* fail) {
ASSERT(kNotStringTag != 0);
ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset));
@@ -1972,6 +1972,18 @@
}
+void MacroAssembler::AbortIfNotString(Register object) {
+ STATIC_ASSERT(kSmiTag == 0);
+ tst(object, Operand(kSmiTagMask));
+ Assert(ne, "Operand is not a string");
+ push(object);
+ ldr(object, FieldMemOperand(object, HeapObject::kMapOffset));
+ CompareInstanceType(object, object, FIRST_NONSTRING_TYPE);
+ pop(object);
+ Assert(lo, "Operand is not a string");
+}
+
+
void MacroAssembler::JumpIfNotHeapNumber(Register object,
Register heap_number_map,
Register scratch,
Index: src/arm/macro-assembler-arm.h
===================================================================
--- src/arm/macro-assembler-arm.h (revision 6774)
+++ src/arm/macro-assembler-arm.h (working copy)
@@ -749,6 +749,9 @@
void AbortIfSmi(Register object);
void AbortIfNotSmi(Register object);
+ // Abort execution if argument is a string. Used in debug code.
+ void AbortIfNotString(Register object);
+
//
---------------------------------------------------------------------------
// HeapNumber utilities
Index: src/ia32/ic-ia32.cc
===================================================================
--- src/ia32/ic-ia32.cc (revision 6774)
+++ src/ia32/ic-ia32.cc (working copy)
@@ -108,6 +108,9 @@
Register name,
Register r0,
Register r1) {
+ // Assert that name contains a string.
+ if (FLAG_debug_code) __ AbortIfNotString(name);
+
// Compute the capacity mask.
const int kCapacityOffset =
StringDictionary::kHeaderSize +
@@ -1212,7 +1215,14 @@
// -- esp[(argc + 1) * 4] : receiver
// -----------------------------------
+ // Check if the name is a string.
+ Label miss;
+ __ test(ecx, Immediate(kSmiTagMask));
+ __ j(zero, &miss);
+ Condition cond = masm->IsObjectStringType(ecx, eax, eax);
+ __ j(NegateCondition(cond), &miss);
GenerateCallNormal(masm, argc);
+ __ bind(&miss);
GenerateMiss(masm, argc);
}
Index: src/x64/ic-x64.cc
===================================================================
--- src/x64/ic-x64.cc (revision 6774)
+++ src/x64/ic-x64.cc (working copy)
@@ -108,6 +108,9 @@
Register name,
Register r0,
Register r1) {
+ // Assert that name contains a string.
+ if (FLAG_debug_code) __ AbortIfNotString(name);
+
// Compute the capacity mask.
const int kCapacityOffset =
StringDictionary::kHeaderSize +
@@ -1238,7 +1241,13 @@
// rsp[(argc + 1) * 8] : argument 0 = receiver
// -----------------------------------
+ // Check if the name is a string.
+ Label miss;
+ __ JumpIfSmi(rcx, &miss);
+ Condition cond = masm->IsObjectStringType(rcx, rax, rax);
+ __ j(NegateCondition(cond), &miss);
GenerateCallNormal(masm, argc);
+ __ bind(&miss);
GenerateMiss(masm, argc);
}
Index: src/x64/macro-assembler-x64.cc
===================================================================
--- src/x64/macro-assembler-x64.cc (revision 6774)
+++ src/x64/macro-assembler-x64.cc (working copy)
@@ -1608,6 +1608,17 @@
}
+void MacroAssembler::AbortIfNotString(Register object) {
+ testb(object, Immediate(kSmiTagMask));
+ Assert(not_equal, "Operand is not a string");
+ push(object);
+ movq(object, FieldOperand(object, HeapObject::kMapOffset));
+ CmpInstanceType(object, FIRST_NONSTRING_TYPE);
+ pop(object);
+ Assert(below, "Operand is not a string");
+}
+
+
void MacroAssembler::AbortIfNotRootValue(Register src,
Heap::RootListIndex
root_value_index,
const char* message) {
Index: src/x64/macro-assembler-x64.h
===================================================================
--- src/x64/macro-assembler-x64.h (revision 6774)
+++ src/x64/macro-assembler-x64.h (working copy)
@@ -647,6 +647,9 @@
// Abort execution if argument is not a smi. Used in debug code.
void AbortIfNotSmi(Register object);
+ // Abort execution if argument is a string. Used in debug code.
+ void AbortIfNotString(Register object);
+
// Abort execution if argument is not the root value with the given
index.
void AbortIfNotRootValue(Register src,
Heap::RootListIndex root_value_index,
Index: test/mjsunit/regress/regress-1146.js
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev