| Index: src/arm/code-stubs-arm.cc
|
| ===================================================================
|
| --- src/arm/code-stubs-arm.cc (revision 8618)
|
| +++ src/arm/code-stubs-arm.cc (working copy)
|
| @@ -69,8 +69,7 @@
|
| void ToNumberStub::Generate(MacroAssembler* masm) {
|
| // The ToNumber stub takes one argument in eax.
|
| Label check_heap_number, call_builtin;
|
| - __ tst(r0, Operand(kSmiTagMask));
|
| - __ b(ne, &check_heap_number);
|
| + __ JumpIfNotSmi(r0, &check_heap_number);
|
| __ Ret();
|
|
|
| __ bind(&check_heap_number);
|
| @@ -158,7 +157,7 @@
|
| __ ldr(r3, MemOperand(sp, 0));
|
|
|
| // Setup the object header.
|
| - __ LoadRoot(r2, Heap::kContextMapRootIndex);
|
| + __ LoadRoot(r2, Heap::kFunctionContextMapRootIndex);
|
| __ str(r2, FieldMemOperand(r0, HeapObject::kMapOffset));
|
| __ mov(r2, Operand(Smi::FromInt(length)));
|
| __ str(r2, FieldMemOperand(r0, FixedArray::kLengthOffset));
|
| @@ -166,11 +165,10 @@
|
| // Setup the fixed slots.
|
| __ mov(r1, Operand(Smi::FromInt(0)));
|
| __ str(r3, MemOperand(r0, Context::SlotOffset(Context::CLOSURE_INDEX)));
|
| - __ str(r0, MemOperand(r0, Context::SlotOffset(Context::FCONTEXT_INDEX)));
|
| - __ str(r1, MemOperand(r0, Context::SlotOffset(Context::PREVIOUS_INDEX)));
|
| + __ str(cp, MemOperand(r0, Context::SlotOffset(Context::PREVIOUS_INDEX)));
|
| __ str(r1, MemOperand(r0, Context::SlotOffset(Context::EXTENSION_INDEX)));
|
|
|
| - // Copy the global object from the surrounding context.
|
| + // Copy the global object from the previous context.
|
| __ ldr(r1, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
|
| __ str(r1, MemOperand(r0, Context::SlotOffset(Context::GLOBAL_INDEX)));
|
|
|
| @@ -187,7 +185,7 @@
|
|
|
| // Need to collect. Call into runtime system.
|
| __ bind(&gc);
|
| - __ TailCallRuntime(Runtime::kNewContext, 1, 1);
|
| + __ TailCallRuntime(Runtime::kNewFunctionContext, 1, 1);
|
| }
|
|
|
|
|
| @@ -306,12 +304,6 @@
|
| }
|
|
|
| void Generate(MacroAssembler* masm);
|
| -
|
| - const char* GetName() { return "ConvertToDoubleStub"; }
|
| -
|
| -#ifdef DEBUG
|
| - void Print() { PrintF("ConvertToDoubleStub\n"); }
|
| -#endif
|
| };
|
|
|
|
|
| @@ -394,11 +386,11 @@
|
| __ mov(scratch1, Operand(r0));
|
| ConvertToDoubleStub stub1(r3, r2, scratch1, scratch2);
|
| __ push(lr);
|
| - __ Call(stub1.GetCode(), RelocInfo::CODE_TARGET);
|
| + __ Call(stub1.GetCode());
|
| // Write Smi from r1 to r1 and r0 in double format.
|
| __ mov(scratch1, Operand(r1));
|
| ConvertToDoubleStub stub2(r1, r0, scratch1, scratch2);
|
| - __ Call(stub2.GetCode(), RelocInfo::CODE_TARGET);
|
| + __ Call(stub2.GetCode());
|
| __ pop(lr);
|
| }
|
| }
|
| @@ -475,7 +467,7 @@
|
| __ mov(scratch1, Operand(object));
|
| ConvertToDoubleStub stub(dst2, dst1, scratch1, scratch2);
|
| __ push(lr);
|
| - __ Call(stub.GetCode(), RelocInfo::CODE_TARGET);
|
| + __ Call(stub.GetCode());
|
| __ pop(lr);
|
| }
|
|
|
| @@ -931,14 +923,14 @@
|
| // They are both equal and they are not both Smis so both of them are not
|
| // Smis. If it's not a heap number, then return equal.
|
| if (cond == lt || cond == gt) {
|
| - __ CompareObjectType(r0, r4, r4, FIRST_JS_OBJECT_TYPE);
|
| + __ CompareObjectType(r0, r4, r4, FIRST_SPEC_OBJECT_TYPE);
|
| __ b(ge, slow);
|
| } else {
|
| __ CompareObjectType(r0, r4, r4, HEAP_NUMBER_TYPE);
|
| __ b(eq, &heap_number);
|
| // Comparing JS objects with <=, >= is complicated.
|
| if (cond != eq) {
|
| - __ cmp(r4, Operand(FIRST_JS_OBJECT_TYPE));
|
| + __ cmp(r4, Operand(FIRST_SPEC_OBJECT_TYPE));
|
| __ b(ge, slow);
|
| // Normally here we fall through to return_equal, but undefined is
|
| // special: (undefined == undefined) == true, but
|
| @@ -1029,8 +1021,7 @@
|
| (lhs.is(r1) && rhs.is(r0)));
|
|
|
| Label rhs_is_smi;
|
| - __ tst(rhs, Operand(kSmiTagMask));
|
| - __ b(eq, &rhs_is_smi);
|
| + __ JumpIfSmi(rhs, &rhs_is_smi);
|
|
|
| // Lhs is a Smi. Check whether the rhs is a heap number.
|
| __ CompareObjectType(rhs, r4, r4, HEAP_NUMBER_TYPE);
|
| @@ -1061,7 +1052,7 @@
|
| // Convert lhs to a double in r2, r3.
|
| __ mov(r7, Operand(lhs));
|
| ConvertToDoubleStub stub1(r3, r2, r7, r6);
|
| - __ Call(stub1.GetCode(), RelocInfo::CODE_TARGET);
|
| + __ Call(stub1.GetCode());
|
| // Load rhs to a double in r0, r1.
|
| __ Ldrd(r0, r1, FieldMemOperand(rhs, HeapNumber::kValueOffset));
|
| __ pop(lr);
|
| @@ -1103,7 +1094,7 @@
|
| // Convert rhs to a double in r0, r1.
|
| __ mov(r7, Operand(rhs));
|
| ConvertToDoubleStub stub2(r1, r0, r7, r6);
|
| - __ Call(stub2.GetCode(), RelocInfo::CODE_TARGET);
|
| + __ Call(stub2.GetCode());
|
| __ pop(lr);
|
| }
|
| // Fall through to both_loaded_as_doubles.
|
| @@ -1220,14 +1211,14 @@
|
| ASSERT((lhs.is(r0) && rhs.is(r1)) ||
|
| (lhs.is(r1) && rhs.is(r0)));
|
|
|
| - // If either operand is a JSObject or an oddball value, then they are
|
| + // If either operand is a JS object or an oddball value, then they are
|
| // not equal since their pointers are different.
|
| // There is no test for undetectability in strict equality.
|
| - STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE);
|
| + STATIC_ASSERT(LAST_TYPE == LAST_CALLABLE_SPEC_OBJECT_TYPE);
|
| Label first_non_object;
|
| // Get the type of the first operand into r2 and compare it with
|
| - // FIRST_JS_OBJECT_TYPE.
|
| - __ CompareObjectType(rhs, r2, r2, FIRST_JS_OBJECT_TYPE);
|
| + // FIRST_SPEC_OBJECT_TYPE.
|
| + __ CompareObjectType(rhs, r2, r2, FIRST_SPEC_OBJECT_TYPE);
|
| __ b(lt, &first_non_object);
|
|
|
| // Return non-zero (r0 is not zero)
|
| @@ -1240,7 +1231,7 @@
|
| __ cmp(r2, Operand(ODDBALL_TYPE));
|
| __ b(eq, &return_not_equal);
|
|
|
| - __ CompareObjectType(lhs, r3, r3, FIRST_JS_OBJECT_TYPE);
|
| + __ CompareObjectType(lhs, r3, r3, FIRST_SPEC_OBJECT_TYPE);
|
| __ b(ge, &return_not_equal);
|
|
|
| // Check for oddballs: true, false, null, undefined.
|
| @@ -1317,9 +1308,9 @@
|
| __ Ret();
|
|
|
| __ bind(&object_test);
|
| - __ cmp(r2, Operand(FIRST_JS_OBJECT_TYPE));
|
| + __ cmp(r2, Operand(FIRST_SPEC_OBJECT_TYPE));
|
| __ b(lt, not_both_strings);
|
| - __ CompareObjectType(lhs, r2, r3, FIRST_JS_OBJECT_TYPE);
|
| + __ CompareObjectType(lhs, r2, r3, FIRST_SPEC_OBJECT_TYPE);
|
| __ b(lt, not_both_strings);
|
| // If both objects are undetectable, they are equal. Otherwise, they
|
| // are not equal, since they are different objects and an object is not
|
| @@ -1458,8 +1449,7 @@
|
| if (include_smi_compare_) {
|
| Label not_two_smis, smi_done;
|
| __ orr(r2, r1, r0);
|
| - __ tst(r2, Operand(kSmiTagMask));
|
| - __ b(ne, ¬_two_smis);
|
| + __ JumpIfNotSmi(r2, ¬_two_smis);
|
| __ mov(r1, Operand(r1, ASR, 1));
|
| __ sub(r0, r1, Operand(r0, ASR, 1));
|
| __ Ret();
|
| @@ -1482,8 +1472,7 @@
|
| STATIC_ASSERT(kSmiTag == 0);
|
| ASSERT_EQ(0, Smi::FromInt(0));
|
| __ and_(r2, lhs_, Operand(rhs_));
|
| - __ tst(r2, Operand(kSmiTagMask));
|
| - __ b(ne, ¬_smis);
|
| + __ JumpIfNotSmi(r2, ¬_smis);
|
| // One operand is a smi. EmitSmiNonsmiComparison generates code that can:
|
| // 1) Return the answer.
|
| // 2) Go to slow.
|
| @@ -1614,15 +1603,13 @@
|
| }
|
|
|
|
|
| -// This stub does not handle the inlined cases (Smis, Booleans, undefined).
|
| // The stub returns zero for false, and a non-zero value for true.
|
| void ToBooleanStub::Generate(MacroAssembler* masm) {
|
| // This stub uses VFP3 instructions.
|
| CpuFeatures::Scope scope(VFP3);
|
|
|
| - Label false_result;
|
| - Label not_heap_number;
|
| - Register scratch = r9.is(tos_) ? r7 : r9;
|
| + Label false_result, true_result, not_string;
|
| + const Register map = r9.is(tos_) ? r7 : r9;
|
|
|
| // undefined -> false
|
| __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
|
| @@ -1652,11 +1639,31 @@
|
| __ cmp(tos_, ip);
|
| __ b(eq, &false_result);
|
|
|
| - // HeapNumber => false iff +0, -0, or NaN.
|
| - __ ldr(scratch, FieldMemOperand(tos_, HeapObject::kMapOffset));
|
| - __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex);
|
| - __ cmp(scratch, ip);
|
| - __ b(¬_heap_number, ne);
|
| + // Get the map of the heap object.
|
| + __ ldr(map, FieldMemOperand(tos_, HeapObject::kMapOffset));
|
| +
|
| + // Undetectable -> false.
|
| + __ ldrb(ip, FieldMemOperand(map, Map::kBitFieldOffset));
|
| + __ tst(ip, Operand(1 << Map::kIsUndetectable));
|
| + __ b(&false_result, ne);
|
| +
|
| + // JavaScript object -> true.
|
| + __ CompareInstanceType(map, ip, FIRST_SPEC_OBJECT_TYPE);
|
| + // "tos_" is a register and contains a non-zero value. Hence we implicitly
|
| + // return true if the greater than condition is satisfied.
|
| + __ Ret(ge);
|
| +
|
| + // String value -> false iff empty.
|
| + __ CompareInstanceType(map, ip, FIRST_NONSTRING_TYPE);
|
| + __ b(¬_string, ge);
|
| + __ ldr(tos_, FieldMemOperand(tos_, String::kLengthOffset));
|
| + // Return string length as boolean value, i.e. return false iff length is 0.
|
| + __ Ret();
|
| +
|
| + __ bind(¬_string);
|
| + // HeapNumber -> false iff +0, -0, or NaN.
|
| + __ CompareRoot(map, Heap::kHeapNumberMapRootIndex);
|
| + __ b(&true_result, ne);
|
| __ vldr(d1, FieldMemOperand(tos_, HeapNumber::kValueOffset));
|
| __ VFPCompareAndSetFlags(d1, 0.0);
|
| // "tos_" is a register, and contains a non zero value by default.
|
| @@ -1666,41 +1673,10 @@
|
| __ mov(tos_, Operand(0, RelocInfo::NONE), LeaveCC, vs); // for FP_NAN
|
| __ Ret();
|
|
|
| - __ bind(¬_heap_number);
|
| -
|
| - // It can be an undetectable object.
|
| - // Undetectable => false.
|
| - __ ldr(ip, FieldMemOperand(tos_, HeapObject::kMapOffset));
|
| - __ ldrb(scratch, FieldMemOperand(ip, Map::kBitFieldOffset));
|
| - __ and_(scratch, scratch, Operand(1 << Map::kIsUndetectable));
|
| - __ cmp(scratch, Operand(1 << Map::kIsUndetectable));
|
| - __ b(&false_result, eq);
|
| -
|
| - // JavaScript object => true.
|
| - __ ldr(scratch, FieldMemOperand(tos_, HeapObject::kMapOffset));
|
| - __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
|
| - __ cmp(scratch, Operand(FIRST_JS_OBJECT_TYPE));
|
| - // "tos_" is a register and contains a non-zero value.
|
| - // Hence we implicitly return true if the greater than
|
| - // condition is satisfied.
|
| - __ Ret(gt);
|
| -
|
| - // Check for string
|
| - __ ldr(scratch, FieldMemOperand(tos_, HeapObject::kMapOffset));
|
| - __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset));
|
| - __ cmp(scratch, Operand(FIRST_NONSTRING_TYPE));
|
| - // "tos_" is a register and contains a non-zero value.
|
| - // Hence we implicitly return true if the greater than
|
| - // condition is satisfied.
|
| - __ Ret(gt);
|
| -
|
| - // String value => false iff empty, i.e., length is zero
|
| - __ ldr(tos_, FieldMemOperand(tos_, String::kLengthOffset));
|
| - // If length is zero, "tos_" contains zero ==> false.
|
| - // If length is not zero, "tos_" contains a non-zero value ==> true.
|
| + // Return 1/0 for true/false in tos_.
|
| + __ bind(&true_result);
|
| + __ mov(tos_, Operand(1, RelocInfo::NONE));
|
| __ Ret();
|
| -
|
| - // Return 0 in "tos_" for false .
|
| __ bind(&false_result);
|
| __ mov(tos_, Operand(0, RelocInfo::NONE));
|
| __ Ret();
|
| @@ -1740,12 +1716,6 @@
|
| }
|
|
|
|
|
| -Handle<Code> GetUnaryOpStub(int key, UnaryOpIC::TypeInfo type_info) {
|
| - UnaryOpStub stub(key, type_info);
|
| - return stub.GetCode();
|
| -}
|
| -
|
| -
|
| const char* UnaryOpStub::GetName() {
|
| if (name_ != NULL) return name_;
|
| const int kMaxNameLength = 100;
|
| @@ -1788,22 +1758,14 @@
|
|
|
|
|
| void UnaryOpStub::GenerateTypeTransition(MacroAssembler* masm) {
|
| - // Prepare to push argument.
|
| - __ mov(r3, Operand(r0));
|
| -
|
| - // Push this stub's key. Although the operation and the type info are
|
| - // encoded into the key, the encoding is opaque, so push them too.
|
| - __ mov(r2, Operand(Smi::FromInt(MinorKey())));
|
| - __ mov(r1, Operand(Smi::FromInt(op_)));
|
| + __ mov(r3, Operand(r0)); // the operand
|
| + __ mov(r2, Operand(Smi::FromInt(op_)));
|
| + __ mov(r1, Operand(Smi::FromInt(mode_)));
|
| __ mov(r0, Operand(Smi::FromInt(operand_type_)));
|
| -
|
| __ Push(r3, r2, r1, r0);
|
|
|
| __ TailCallExternalReference(
|
| - ExternalReference(IC_Utility(IC::kUnaryOp_Patch),
|
| - masm->isolate()),
|
| - 4,
|
| - 1);
|
| + ExternalReference(IC_Utility(IC::kUnaryOp_Patch), masm->isolate()), 4, 1);
|
| }
|
|
|
|
|
| @@ -2052,14 +2014,6 @@
|
| }
|
|
|
|
|
| -Handle<Code> GetBinaryOpStub(int key,
|
| - BinaryOpIC::TypeInfo type_info,
|
| - BinaryOpIC::TypeInfo result_type_info) {
|
| - BinaryOpStub stub(key, type_info, result_type_info);
|
| - return stub.GetCode();
|
| -}
|
| -
|
| -
|
| void BinaryOpStub::GenerateTypeTransition(MacroAssembler* masm) {
|
| Label get_result;
|
|
|
| @@ -2494,8 +2448,7 @@
|
| // Perform combined smi check on both operands.
|
| __ orr(scratch1, left, Operand(right));
|
| STATIC_ASSERT(kSmiTag == 0);
|
| - __ tst(scratch1, Operand(kSmiTagMask));
|
| - __ b(ne, ¬_smis);
|
| + __ JumpIfNotSmi(scratch1, ¬_smis);
|
|
|
| // If the smi-smi operation results in a smi return is generated.
|
| GenerateSmiSmiOperation(masm);
|
| @@ -2608,37 +2561,36 @@
|
| case Token::MUL:
|
| case Token::DIV:
|
| case Token::MOD: {
|
| - // Load both operands and check that they are 32-bit integer.
|
| - // Jump to type transition if they are not. The registers r0 and r1 (right
|
| - // and left) are preserved for the runtime call.
|
| - FloatingPointHelper::Destination destination =
|
| - CpuFeatures::IsSupported(VFP3) &&
|
| - op_ != Token::MOD ?
|
| - FloatingPointHelper::kVFPRegisters :
|
| - FloatingPointHelper::kCoreRegisters;
|
| + // Load both operands and check that they are 32-bit integer.
|
| + // Jump to type transition if they are not. The registers r0 and r1 (right
|
| + // and left) are preserved for the runtime call.
|
| + FloatingPointHelper::Destination destination =
|
| + (CpuFeatures::IsSupported(VFP3) && op_ != Token::MOD)
|
| + ? FloatingPointHelper::kVFPRegisters
|
| + : FloatingPointHelper::kCoreRegisters;
|
|
|
| - FloatingPointHelper::LoadNumberAsInt32Double(masm,
|
| - right,
|
| - destination,
|
| - d7,
|
| - r2,
|
| - r3,
|
| - heap_number_map,
|
| - scratch1,
|
| - scratch2,
|
| - s0,
|
| - &transition);
|
| - FloatingPointHelper::LoadNumberAsInt32Double(masm,
|
| - left,
|
| - destination,
|
| - d6,
|
| - r4,
|
| - r5,
|
| - heap_number_map,
|
| - scratch1,
|
| - scratch2,
|
| - s0,
|
| - &transition);
|
| + FloatingPointHelper::LoadNumberAsInt32Double(masm,
|
| + right,
|
| + destination,
|
| + d7,
|
| + r2,
|
| + r3,
|
| + heap_number_map,
|
| + scratch1,
|
| + scratch2,
|
| + s0,
|
| + &transition);
|
| + FloatingPointHelper::LoadNumberAsInt32Double(masm,
|
| + left,
|
| + destination,
|
| + d6,
|
| + r4,
|
| + r5,
|
| + heap_number_map,
|
| + scratch1,
|
| + scratch2,
|
| + s0,
|
| + &transition);
|
|
|
| if (destination == FloatingPointHelper::kVFPRegisters) {
|
| CpuFeatures::Scope scope(VFP3);
|
| @@ -2699,9 +2651,11 @@
|
| // DIV just falls through to allocating a heap number.
|
| }
|
|
|
| - if (result_type_ >= (op_ == Token::DIV) ? BinaryOpIC::HEAP_NUMBER
|
| - : BinaryOpIC::INT32) {
|
| - __ bind(&return_heap_number);
|
| + __ bind(&return_heap_number);
|
| + // Return a heap number, or fall through to type transition or runtime
|
| + // call if we can't.
|
| + if (result_type_ >= ((op_ == Token::DIV) ? BinaryOpIC::HEAP_NUMBER
|
| + : BinaryOpIC::INT32)) {
|
| // We are using vfp registers so r5 is available.
|
| heap_number_result = r5;
|
| GenerateHeapResultAllocation(masm,
|
| @@ -2875,7 +2829,11 @@
|
| UNREACHABLE();
|
| }
|
|
|
| - if (transition.is_linked()) {
|
| + // We never expect DIV to yield an integer result, so we always generate
|
| + // type transition code for DIV operations expecting an integer result: the
|
| + // code will fall through to this type transition.
|
| + if (transition.is_linked() ||
|
| + ((op_ == Token::DIV) && (result_type_ <= BinaryOpIC::INT32))) {
|
| __ bind(&transition);
|
| GenerateTypeTransition(masm);
|
| }
|
| @@ -3444,15 +3402,10 @@
|
|
|
| __ mov(r2, Operand(ExternalReference::isolate_address()));
|
|
|
| -
|
| - // TODO(1242173): To let the GC traverse the return address of the exit
|
| - // frames, we need to know where the return address is. Right now,
|
| - // we store it on the stack to be able to find it again, but we never
|
| - // restore from it in case of changes, which makes it impossible to
|
| - // support moving the C entry code stub. This should be fixed, but currently
|
| - // this is OK because the CEntryStub gets generated so early in the V8 boot
|
| - // sequence that it is not moving ever.
|
| -
|
| + // To let the GC traverse the return address of the exit frames, we need to
|
| + // know where the return address is. The CEntryStub is unmovable, so
|
| + // we can store the address on the stack to be able to find it again and
|
| + // we never have to restore it, because it will not change.
|
| // Compute the return address in lr to return to after the jump below. Pc is
|
| // already at '+ 8' from the current instruction but return is after three
|
| // instructions so add another 4 to pc to get the return address.
|
| @@ -3602,13 +3555,27 @@
|
| // Save callee-saved registers (incl. cp and fp), sp, and lr
|
| __ stm(db_w, sp, kCalleeSaved | lr.bit());
|
|
|
| + if (CpuFeatures::IsSupported(VFP3)) {
|
| + CpuFeatures::Scope scope(VFP3);
|
| + // Save callee-saved vfp registers.
|
| + __ vstm(db_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg);
|
| + // Set up the reserved register for 0.0.
|
| + __ vmov(kDoubleRegZero, 0.0);
|
| + }
|
| +
|
| // Get address of argv, see stm above.
|
| // r0: code entry
|
| // r1: function
|
| // r2: receiver
|
| // r3: argc
|
| - __ ldr(r4, MemOperand(sp, (kNumCalleeSaved + 1) * kPointerSize)); // argv
|
|
|
| + // Setup argv in r4.
|
| + int offset_to_argv = (kNumCalleeSaved + 1) * kPointerSize;
|
| + if (CpuFeatures::IsSupported(VFP3)) {
|
| + offset_to_argv += kNumDoubleCalleeSaved * kDoubleSize;
|
| + }
|
| + __ ldr(r4, MemOperand(sp, offset_to_argv));
|
| +
|
| // Push a frame with special values setup to mark it as an entry frame.
|
| // r0: code entry
|
| // r1: function
|
| @@ -3732,6 +3699,13 @@
|
| __ mov(lr, Operand(pc));
|
| }
|
| #endif
|
| +
|
| + if (CpuFeatures::IsSupported(VFP3)) {
|
| + CpuFeatures::Scope scope(VFP3);
|
| + // Restore callee-saved vfp registers.
|
| + __ vldm(ia_w, sp, kFirstCalleeSavedDoubleReg, kLastCalleeSavedDoubleReg);
|
| + }
|
| +
|
| __ ldm(ia_w, sp, kCalleeSaved | pc.bit());
|
| }
|
|
|
| @@ -3971,12 +3945,233 @@
|
| }
|
|
|
|
|
| -void ArgumentsAccessStub::GenerateNewObject(MacroAssembler* masm) {
|
| +void ArgumentsAccessStub::GenerateNewNonStrictSlow(MacroAssembler* masm) {
|
| // sp[0] : number of parameters
|
| // sp[4] : receiver displacement
|
| // sp[8] : function
|
|
|
| // Check if the calling frame is an arguments adaptor frame.
|
| + Label runtime;
|
| + __ ldr(r3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
|
| + __ ldr(r2, MemOperand(r3, StandardFrameConstants::kContextOffset));
|
| + __ cmp(r2, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
|
| + __ b(ne, &runtime);
|
| +
|
| + // Patch the arguments.length and the parameters pointer in the current frame.
|
| + __ ldr(r2, MemOperand(r3, ArgumentsAdaptorFrameConstants::kLengthOffset));
|
| + __ str(r2, MemOperand(sp, 0 * kPointerSize));
|
| + __ add(r3, r3, Operand(r2, LSL, 1));
|
| + __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset));
|
| + __ str(r3, MemOperand(sp, 1 * kPointerSize));
|
| +
|
| + __ bind(&runtime);
|
| + __ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1);
|
| +}
|
| +
|
| +
|
| +void ArgumentsAccessStub::GenerateNewNonStrictFast(MacroAssembler* masm) {
|
| + // Stack layout:
|
| + // sp[0] : number of parameters (tagged)
|
| + // sp[4] : address of receiver argument
|
| + // sp[8] : function
|
| + // Registers used over whole function:
|
| + // r6 : allocated object (tagged)
|
| + // r9 : mapped parameter count (tagged)
|
| +
|
| + __ ldr(r1, MemOperand(sp, 0 * kPointerSize));
|
| + // r1 = parameter count (tagged)
|
| +
|
| + // Check if the calling frame is an arguments adaptor frame.
|
| + Label runtime;
|
| + Label adaptor_frame, try_allocate;
|
| + __ ldr(r3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
|
| + __ ldr(r2, MemOperand(r3, StandardFrameConstants::kContextOffset));
|
| + __ cmp(r2, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
|
| + __ b(eq, &adaptor_frame);
|
| +
|
| + // No adaptor, parameter count = argument count.
|
| + __ mov(r2, r1);
|
| + __ b(&try_allocate);
|
| +
|
| + // We have an adaptor frame. Patch the parameters pointer.
|
| + __ bind(&adaptor_frame);
|
| + __ ldr(r2, MemOperand(r3, ArgumentsAdaptorFrameConstants::kLengthOffset));
|
| + __ add(r3, r3, Operand(r2, LSL, 1));
|
| + __ add(r3, r3, Operand(StandardFrameConstants::kCallerSPOffset));
|
| + __ str(r3, MemOperand(sp, 1 * kPointerSize));
|
| +
|
| + // r1 = parameter count (tagged)
|
| + // r2 = argument count (tagged)
|
| + // Compute the mapped parameter count = min(r1, r2) in r1.
|
| + __ cmp(r1, Operand(r2));
|
| + __ mov(r1, Operand(r2), LeaveCC, gt);
|
| +
|
| + __ bind(&try_allocate);
|
| +
|
| + // Compute the sizes of backing store, parameter map, and arguments object.
|
| + // 1. Parameter map, has 2 extra words containing context and backing store.
|
| + const int kParameterMapHeaderSize =
|
| + FixedArray::kHeaderSize + 2 * kPointerSize;
|
| + // If there are no mapped parameters, we do not need the parameter_map.
|
| + __ cmp(r1, Operand(Smi::FromInt(0)));
|
| + __ mov(r9, Operand(0), LeaveCC, eq);
|
| + __ mov(r9, Operand(r1, LSL, 1), LeaveCC, ne);
|
| + __ add(r9, r9, Operand(kParameterMapHeaderSize), LeaveCC, ne);
|
| +
|
| + // 2. Backing store.
|
| + __ add(r9, r9, Operand(r2, LSL, 1));
|
| + __ add(r9, r9, Operand(FixedArray::kHeaderSize));
|
| +
|
| + // 3. Arguments object.
|
| + __ add(r9, r9, Operand(Heap::kArgumentsObjectSize));
|
| +
|
| + // Do the allocation of all three objects in one go.
|
| + __ AllocateInNewSpace(r9, r0, r3, r4, &runtime, TAG_OBJECT);
|
| +
|
| + // r0 = address of new object(s) (tagged)
|
| + // r2 = argument count (tagged)
|
| + // Get the arguments boilerplate from the current (global) context into r4.
|
| + const int kNormalOffset =
|
| + Context::SlotOffset(Context::ARGUMENTS_BOILERPLATE_INDEX);
|
| + const int kAliasedOffset =
|
| + Context::SlotOffset(Context::ALIASED_ARGUMENTS_BOILERPLATE_INDEX);
|
| +
|
| + __ ldr(r4, MemOperand(r8, Context::SlotOffset(Context::GLOBAL_INDEX)));
|
| + __ ldr(r4, FieldMemOperand(r4, GlobalObject::kGlobalContextOffset));
|
| + __ cmp(r1, Operand(0));
|
| + __ ldr(r4, MemOperand(r4, kNormalOffset), eq);
|
| + __ ldr(r4, MemOperand(r4, kAliasedOffset), ne);
|
| +
|
| + // r0 = address of new object (tagged)
|
| + // r1 = mapped parameter count (tagged)
|
| + // r2 = argument count (tagged)
|
| + // r4 = address of boilerplate object (tagged)
|
| + // Copy the JS object part.
|
| + for (int i = 0; i < JSObject::kHeaderSize; i += kPointerSize) {
|
| + __ ldr(r3, FieldMemOperand(r4, i));
|
| + __ str(r3, FieldMemOperand(r0, i));
|
| + }
|
| +
|
| + // Setup the callee in-object property.
|
| + STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1);
|
| + __ ldr(r3, MemOperand(sp, 2 * kPointerSize));
|
| + const int kCalleeOffset = JSObject::kHeaderSize +
|
| + Heap::kArgumentsCalleeIndex * kPointerSize;
|
| + __ str(r3, FieldMemOperand(r0, kCalleeOffset));
|
| +
|
| + // Use the length (smi tagged) and set that as an in-object property too.
|
| + STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0);
|
| + const int kLengthOffset = JSObject::kHeaderSize +
|
| + Heap::kArgumentsLengthIndex * kPointerSize;
|
| + __ str(r2, FieldMemOperand(r0, kLengthOffset));
|
| +
|
| + // Setup the elements pointer in the allocated arguments object.
|
| + // If we allocated a parameter map, r4 will point there, otherwise
|
| + // it will point to the backing store.
|
| + __ add(r4, r0, Operand(Heap::kArgumentsObjectSize));
|
| + __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset));
|
| +
|
| + // r0 = address of new object (tagged)
|
| + // r1 = mapped parameter count (tagged)
|
| + // r2 = argument count (tagged)
|
| + // r4 = address of parameter map or backing store (tagged)
|
| + // Initialize parameter map. If there are no mapped arguments, we're done.
|
| + Label skip_parameter_map;
|
| + __ cmp(r1, Operand(Smi::FromInt(0)));
|
| + // Move backing store address to r3, because it is
|
| + // expected there when filling in the unmapped arguments.
|
| + __ mov(r3, r4, LeaveCC, eq);
|
| + __ b(eq, &skip_parameter_map);
|
| +
|
| + __ LoadRoot(r6, Heap::kNonStrictArgumentsElementsMapRootIndex);
|
| + __ str(r6, FieldMemOperand(r4, FixedArray::kMapOffset));
|
| + __ add(r6, r1, Operand(Smi::FromInt(2)));
|
| + __ str(r6, FieldMemOperand(r4, FixedArray::kLengthOffset));
|
| + __ str(r8, FieldMemOperand(r4, FixedArray::kHeaderSize + 0 * kPointerSize));
|
| + __ add(r6, r4, Operand(r1, LSL, 1));
|
| + __ add(r6, r6, Operand(kParameterMapHeaderSize));
|
| + __ str(r6, FieldMemOperand(r4, FixedArray::kHeaderSize + 1 * kPointerSize));
|
| +
|
| + // Copy the parameter slots and the holes in the arguments.
|
| + // We need to fill in mapped_parameter_count slots. They index the context,
|
| + // where parameters are stored in reverse order, at
|
| + // MIN_CONTEXT_SLOTS .. MIN_CONTEXT_SLOTS+parameter_count-1
|
| + // The mapped parameter thus need to get indices
|
| + // MIN_CONTEXT_SLOTS+parameter_count-1 ..
|
| + // MIN_CONTEXT_SLOTS+parameter_count-mapped_parameter_count
|
| + // We loop from right to left.
|
| + Label parameters_loop, parameters_test;
|
| + __ mov(r6, r1);
|
| + __ ldr(r9, MemOperand(sp, 0 * kPointerSize));
|
| + __ add(r9, r9, Operand(Smi::FromInt(Context::MIN_CONTEXT_SLOTS)));
|
| + __ sub(r9, r9, Operand(r1));
|
| + __ LoadRoot(r7, Heap::kTheHoleValueRootIndex);
|
| + __ add(r3, r4, Operand(r6, LSL, 1));
|
| + __ add(r3, r3, Operand(kParameterMapHeaderSize));
|
| +
|
| + // r6 = loop variable (tagged)
|
| + // r1 = mapping index (tagged)
|
| + // r3 = address of backing store (tagged)
|
| + // r4 = address of parameter map (tagged)
|
| + // r5 = temporary scratch (a.o., for address calculation)
|
| + // r7 = the hole value
|
| + __ jmp(¶meters_test);
|
| +
|
| + __ bind(¶meters_loop);
|
| + __ sub(r6, r6, Operand(Smi::FromInt(1)));
|
| + __ mov(r5, Operand(r6, LSL, 1));
|
| + __ add(r5, r5, Operand(kParameterMapHeaderSize - kHeapObjectTag));
|
| + __ str(r9, MemOperand(r4, r5));
|
| + __ sub(r5, r5, Operand(kParameterMapHeaderSize - FixedArray::kHeaderSize));
|
| + __ str(r7, MemOperand(r3, r5));
|
| + __ add(r9, r9, Operand(Smi::FromInt(1)));
|
| + __ bind(¶meters_test);
|
| + __ cmp(r6, Operand(Smi::FromInt(0)));
|
| + __ b(ne, ¶meters_loop);
|
| +
|
| + __ bind(&skip_parameter_map);
|
| + // r2 = argument count (tagged)
|
| + // r3 = address of backing store (tagged)
|
| + // r5 = scratch
|
| + // Copy arguments header and remaining slots (if there are any).
|
| + __ LoadRoot(r5, Heap::kFixedArrayMapRootIndex);
|
| + __ str(r5, FieldMemOperand(r3, FixedArray::kMapOffset));
|
| + __ str(r2, FieldMemOperand(r3, FixedArray::kLengthOffset));
|
| +
|
| + Label arguments_loop, arguments_test;
|
| + __ mov(r9, r1);
|
| + __ ldr(r4, MemOperand(sp, 1 * kPointerSize));
|
| + __ sub(r4, r4, Operand(r9, LSL, 1));
|
| + __ jmp(&arguments_test);
|
| +
|
| + __ bind(&arguments_loop);
|
| + __ sub(r4, r4, Operand(kPointerSize));
|
| + __ ldr(r6, MemOperand(r4, 0));
|
| + __ add(r5, r3, Operand(r9, LSL, 1));
|
| + __ str(r6, FieldMemOperand(r5, FixedArray::kHeaderSize));
|
| + __ add(r9, r9, Operand(Smi::FromInt(1)));
|
| +
|
| + __ bind(&arguments_test);
|
| + __ cmp(r9, Operand(r2));
|
| + __ b(lt, &arguments_loop);
|
| +
|
| + // Return and remove the on-stack parameters.
|
| + __ add(sp, sp, Operand(3 * kPointerSize));
|
| + __ Ret();
|
| +
|
| + // Do the runtime call to allocate the arguments object.
|
| + // r2 = argument count (taggged)
|
| + __ bind(&runtime);
|
| + __ str(r2, MemOperand(sp, 0 * kPointerSize)); // Patch argument count.
|
| + __ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1);
|
| +}
|
| +
|
| +
|
| +void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) {
|
| + // sp[0] : number of parameters
|
| + // sp[4] : receiver displacement
|
| + // sp[8] : function
|
| + // Check if the calling frame is an arguments adaptor frame.
|
| Label adaptor_frame, try_allocate, runtime;
|
| __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset));
|
| __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset));
|
| @@ -4004,40 +4199,31 @@
|
| __ mov(r1, Operand(r1, LSR, kSmiTagSize));
|
| __ add(r1, r1, Operand(FixedArray::kHeaderSize / kPointerSize));
|
| __ bind(&add_arguments_object);
|
| - __ add(r1, r1, Operand(GetArgumentsObjectSize() / kPointerSize));
|
| + __ add(r1, r1, Operand(Heap::kArgumentsObjectSizeStrict / kPointerSize));
|
|
|
| // Do the allocation of both objects in one go.
|
| - __ AllocateInNewSpace(
|
| - r1,
|
| - r0,
|
| - r2,
|
| - r3,
|
| - &runtime,
|
| - static_cast<AllocationFlags>(TAG_OBJECT | SIZE_IN_WORDS));
|
| + __ AllocateInNewSpace(r1,
|
| + r0,
|
| + r2,
|
| + r3,
|
| + &runtime,
|
| + static_cast<AllocationFlags>(TAG_OBJECT |
|
| + SIZE_IN_WORDS));
|
|
|
| // Get the arguments boilerplate from the current (global) context.
|
| __ ldr(r4, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX)));
|
| __ ldr(r4, FieldMemOperand(r4, GlobalObject::kGlobalContextOffset));
|
| - __ ldr(r4, MemOperand(r4,
|
| - Context::SlotOffset(GetArgumentsBoilerplateIndex())));
|
| + __ ldr(r4, MemOperand(r4, Context::SlotOffset(
|
| + Context::STRICT_MODE_ARGUMENTS_BOILERPLATE_INDEX)));
|
|
|
| // Copy the JS object part.
|
| __ CopyFields(r0, r4, r3.bit(), JSObject::kHeaderSize / kPointerSize);
|
|
|
| - if (type_ == NEW_NON_STRICT) {
|
| - // Setup the callee in-object property.
|
| - STATIC_ASSERT(Heap::kArgumentsCalleeIndex == 1);
|
| - __ ldr(r3, MemOperand(sp, 2 * kPointerSize));
|
| - const int kCalleeOffset = JSObject::kHeaderSize +
|
| - Heap::kArgumentsCalleeIndex * kPointerSize;
|
| - __ str(r3, FieldMemOperand(r0, kCalleeOffset));
|
| - }
|
| -
|
| // Get the length (smi tagged) and set that as an in-object property too.
|
| STATIC_ASSERT(Heap::kArgumentsLengthIndex == 0);
|
| __ ldr(r1, MemOperand(sp, 0 * kPointerSize));
|
| __ str(r1, FieldMemOperand(r0, JSObject::kHeaderSize +
|
| - Heap::kArgumentsLengthIndex * kPointerSize));
|
| + Heap::kArgumentsLengthIndex * kPointerSize));
|
|
|
| // If there are no actual arguments, we're done.
|
| Label done;
|
| @@ -4049,12 +4235,13 @@
|
|
|
| // Setup the elements pointer in the allocated arguments object and
|
| // initialize the header in the elements fixed array.
|
| - __ add(r4, r0, Operand(GetArgumentsObjectSize()));
|
| + __ add(r4, r0, Operand(Heap::kArgumentsObjectSizeStrict));
|
| __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset));
|
| __ LoadRoot(r3, Heap::kFixedArrayMapRootIndex);
|
| __ str(r3, FieldMemOperand(r4, FixedArray::kMapOffset));
|
| __ str(r1, FieldMemOperand(r4, FixedArray::kLengthOffset));
|
| - __ mov(r1, Operand(r1, LSR, kSmiTagSize)); // Untag the length for the loop.
|
| + // Untag the length for the loop.
|
| + __ mov(r1, Operand(r1, LSR, kSmiTagSize));
|
|
|
| // Copy the fixed array slots.
|
| Label loop;
|
| @@ -4077,7 +4264,7 @@
|
|
|
| // Do the runtime call to allocate the arguments object.
|
| __ bind(&runtime);
|
| - __ TailCallRuntime(Runtime::kNewArgumentsFast, 3, 1);
|
| + __ TailCallRuntime(Runtime::kNewStrictArgumentsFast, 3, 1);
|
| }
|
|
|
|
|
| @@ -4129,8 +4316,7 @@
|
| // Check that the first argument is a JSRegExp object.
|
| __ ldr(r0, MemOperand(sp, kJSRegExpOffset));
|
| STATIC_ASSERT(kSmiTag == 0);
|
| - __ tst(r0, Operand(kSmiTagMask));
|
| - __ b(eq, &runtime);
|
| + __ JumpIfSmi(r0, &runtime);
|
| __ CompareObjectType(r0, r1, r1, JS_REGEXP_TYPE);
|
| __ b(ne, &runtime);
|
|
|
| @@ -4166,8 +4352,7 @@
|
| // regexp_data: RegExp data (FixedArray)
|
| // Check that the second argument is a string.
|
| __ ldr(subject, MemOperand(sp, kSubjectOffset));
|
| - __ tst(subject, Operand(kSmiTagMask));
|
| - __ b(eq, &runtime);
|
| + __ JumpIfSmi(subject, &runtime);
|
| Condition is_string = masm->IsObjectStringType(subject, r0);
|
| __ b(NegateCondition(is_string), &runtime);
|
| // Get the length of the string to r3.
|
| @@ -4180,8 +4365,7 @@
|
| // Check that the third argument is a positive smi less than the subject
|
| // string length. A negative value will be greater (unsigned comparison).
|
| __ ldr(r0, MemOperand(sp, kPreviousIndexOffset));
|
| - __ tst(r0, Operand(kSmiTagMask));
|
| - __ b(ne, &runtime);
|
| + __ JumpIfNotSmi(r0, &runtime);
|
| __ cmp(r3, Operand(r0));
|
| __ b(ls, &runtime);
|
|
|
| @@ -4190,8 +4374,7 @@
|
| // regexp_data: RegExp data (FixedArray)
|
| // Check that the fourth object is a JSArray object.
|
| __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset));
|
| - __ tst(r0, Operand(kSmiTagMask));
|
| - __ b(eq, &runtime);
|
| + __ JumpIfSmi(r0, &runtime);
|
| __ CompareObjectType(r0, r1, r1, JS_ARRAY_TYPE);
|
| __ b(ne, &runtime);
|
| // Check that the JSArray is in fast case.
|
| @@ -4257,9 +4440,8 @@
|
|
|
| // Check that the irregexp code has been generated for the actual string
|
| // encoding. If it has, the field contains a code object otherwise it contains
|
| - // the hole.
|
| - __ CompareObjectType(r7, r0, r0, CODE_TYPE);
|
| - __ b(ne, &runtime);
|
| + // a smi (code flushing support).
|
| + __ JumpIfSmi(r7, &runtime);
|
|
|
| // r3: encoding of subject string (1 if ASCII, 0 if two_byte);
|
| // r7: code
|
| @@ -4460,8 +4642,7 @@
|
| __ ldr(r1, MemOperand(sp, kPointerSize * 2));
|
| STATIC_ASSERT(kSmiTag == 0);
|
| STATIC_ASSERT(kSmiTagSize == 1);
|
| - __ tst(r1, Operand(kSmiTagMask));
|
| - __ b(ne, &slowcase);
|
| + __ JumpIfNotSmi(r1, &slowcase);
|
| __ cmp(r1, Operand(Smi::FromInt(kMaxInlineLength)));
|
| __ b(hi, &slowcase);
|
| // Smi-tagging is equivalent to multiplying by 2.
|
| @@ -4582,7 +4763,11 @@
|
| Label call_as_function;
|
| __ CompareRoot(r4, Heap::kTheHoleValueRootIndex);
|
| __ b(eq, &call_as_function);
|
| - __ InvokeFunction(r1, actual, JUMP_FUNCTION);
|
| + __ InvokeFunction(r1,
|
| + actual,
|
| + JUMP_FUNCTION,
|
| + NullCallWrapper(),
|
| + CALL_AS_METHOD);
|
| __ bind(&call_as_function);
|
| }
|
| __ InvokeFunction(r1,
|
| @@ -5338,8 +5523,7 @@
|
| // Make sure first argument is a sequential (or flat) string.
|
| __ ldr(r5, MemOperand(sp, kStringOffset));
|
| STATIC_ASSERT(kSmiTag == 0);
|
| - __ tst(r5, Operand(kSmiTagMask));
|
| - __ b(eq, &runtime);
|
| + __ JumpIfSmi(r5, &runtime);
|
| Condition is_string = masm->IsObjectStringType(r5, r1);
|
| __ b(NegateCondition(is_string), &runtime);
|
|
|
| @@ -5976,8 +6160,7 @@
|
| ASSERT(state_ == CompareIC::SMIS);
|
| Label miss;
|
| __ orr(r2, r1, r0);
|
| - __ tst(r2, Operand(kSmiTagMask));
|
| - __ b(ne, &miss);
|
| + __ JumpIfNotSmi(r2, &miss);
|
|
|
| if (GetCondition() == eq) {
|
| // For equality we do not care about the sign of the result.
|
| @@ -6001,8 +6184,7 @@
|
| Label unordered;
|
| Label miss;
|
| __ and_(r2, r1, Operand(r0));
|
| - __ tst(r2, Operand(kSmiTagMask));
|
| - __ b(eq, &generic_stub);
|
| + __ JumpIfSmi(r2, &generic_stub);
|
|
|
| __ CompareObjectType(r0, r2, r2, HEAP_NUMBER_TYPE);
|
| __ b(ne, &miss);
|
| @@ -6151,8 +6333,7 @@
|
| ASSERT(state_ == CompareIC::OBJECTS);
|
| Label miss;
|
| __ and_(r2, r1, Operand(r0));
|
| - __ tst(r2, Operand(kSmiTagMask));
|
| - __ b(eq, &miss);
|
| + __ JumpIfSmi(r2, &miss);
|
|
|
| __ CompareObjectType(r0, r2, r2, JS_OBJECT_TYPE);
|
| __ b(ne, &miss);
|
|
|