| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 } | 424 } |
| 425 | 425 |
| 426 | 426 |
| 427 void LCodeGen::DoCallFunction(LCallFunction* instr) { | 427 void LCodeGen::DoCallFunction(LCallFunction* instr) { |
| 428 ASSERT(ToRegister(instr->context()).is(cp)); | 428 ASSERT(ToRegister(instr->context()).is(cp)); |
| 429 ASSERT(ToRegister(instr->function()).Is(x1)); | 429 ASSERT(ToRegister(instr->function()).Is(x1)); |
| 430 ASSERT(ToRegister(instr->result()).Is(x0)); | 430 ASSERT(ToRegister(instr->result()).Is(x0)); |
| 431 | 431 |
| 432 int arity = instr->arity(); | 432 int arity = instr->arity(); |
| 433 CallFunctionStub stub(isolate(), arity, instr->hydrogen()->function_flags()); | 433 CallFunctionStub stub(isolate(), arity, instr->hydrogen()->function_flags()); |
| 434 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 434 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 435 } | 435 } |
| 436 | 436 |
| 437 | 437 |
| 438 void LCodeGen::DoCallNew(LCallNew* instr) { | 438 void LCodeGen::DoCallNew(LCallNew* instr) { |
| 439 ASSERT(ToRegister(instr->context()).is(cp)); | 439 ASSERT(ToRegister(instr->context()).is(cp)); |
| 440 ASSERT(instr->IsMarkedAsCall()); | 440 ASSERT(instr->IsMarkedAsCall()); |
| 441 ASSERT(ToRegister(instr->constructor()).is(x1)); | 441 ASSERT(ToRegister(instr->constructor()).is(x1)); |
| 442 | 442 |
| 443 __ Mov(x0, instr->arity()); | 443 __ Mov(x0, instr->arity()); |
| 444 // No cell in x2 for construct type feedback in optimized code. | 444 // No cell in x2 for construct type feedback in optimized code. |
| 445 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex); | 445 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex); |
| 446 | 446 |
| 447 CallConstructStub stub(isolate(), NO_CALL_FUNCTION_FLAGS); | 447 CallConstructStub stub(isolate(), NO_CALL_FUNCTION_FLAGS); |
| 448 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); | 448 CallCode(stub.GetCode(), RelocInfo::CONSTRUCT_CALL, instr); |
| 449 | 449 |
| 450 ASSERT(ToRegister(instr->result()).is(x0)); | 450 ASSERT(ToRegister(instr->result()).is(x0)); |
| 451 } | 451 } |
| 452 | 452 |
| 453 | 453 |
| 454 void LCodeGen::DoCallNewArray(LCallNewArray* instr) { | 454 void LCodeGen::DoCallNewArray(LCallNewArray* instr) { |
| 455 ASSERT(instr->IsMarkedAsCall()); | 455 ASSERT(instr->IsMarkedAsCall()); |
| 456 ASSERT(ToRegister(instr->context()).is(cp)); | 456 ASSERT(ToRegister(instr->context()).is(cp)); |
| 457 ASSERT(ToRegister(instr->constructor()).is(x1)); | 457 ASSERT(ToRegister(instr->constructor()).is(x1)); |
| 458 | 458 |
| 459 __ Mov(x0, Operand(instr->arity())); | 459 __ Mov(x0, Operand(instr->arity())); |
| 460 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex); | 460 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex); |
| 461 | 461 |
| 462 ElementsKind kind = instr->hydrogen()->elements_kind(); | 462 ElementsKind kind = instr->hydrogen()->elements_kind(); |
| 463 AllocationSiteOverrideMode override_mode = | 463 AllocationSiteOverrideMode override_mode = |
| 464 (AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE) | 464 (AllocationSite::GetMode(kind) == TRACK_ALLOCATION_SITE) |
| 465 ? DISABLE_ALLOCATION_SITES | 465 ? DISABLE_ALLOCATION_SITES |
| 466 : DONT_OVERRIDE; | 466 : DONT_OVERRIDE; |
| 467 | 467 |
| 468 if (instr->arity() == 0) { | 468 if (instr->arity() == 0) { |
| 469 ArrayNoArgumentConstructorStub stub(isolate(), kind, override_mode); | 469 ArrayNoArgumentConstructorStub stub(isolate(), kind, override_mode); |
| 470 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); | 470 CallCode(stub.GetCode(), RelocInfo::CONSTRUCT_CALL, instr); |
| 471 } else if (instr->arity() == 1) { | 471 } else if (instr->arity() == 1) { |
| 472 Label done; | 472 Label done; |
| 473 if (IsFastPackedElementsKind(kind)) { | 473 if (IsFastPackedElementsKind(kind)) { |
| 474 Label packed_case; | 474 Label packed_case; |
| 475 | 475 |
| 476 // We might need to create a holey array; look at the first argument. | 476 // We might need to create a holey array; look at the first argument. |
| 477 __ Peek(x10, 0); | 477 __ Peek(x10, 0); |
| 478 __ Cbz(x10, &packed_case); | 478 __ Cbz(x10, &packed_case); |
| 479 | 479 |
| 480 ElementsKind holey_kind = GetHoleyElementsKind(kind); | 480 ElementsKind holey_kind = GetHoleyElementsKind(kind); |
| 481 ArraySingleArgumentConstructorStub stub(isolate(), | 481 ArraySingleArgumentConstructorStub stub(isolate(), |
| 482 holey_kind, | 482 holey_kind, |
| 483 override_mode); | 483 override_mode); |
| 484 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); | 484 CallCode(stub.GetCode(), RelocInfo::CONSTRUCT_CALL, instr); |
| 485 __ B(&done); | 485 __ B(&done); |
| 486 __ Bind(&packed_case); | 486 __ Bind(&packed_case); |
| 487 } | 487 } |
| 488 | 488 |
| 489 ArraySingleArgumentConstructorStub stub(isolate(), kind, override_mode); | 489 ArraySingleArgumentConstructorStub stub(isolate(), kind, override_mode); |
| 490 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); | 490 CallCode(stub.GetCode(), RelocInfo::CONSTRUCT_CALL, instr); |
| 491 __ Bind(&done); | 491 __ Bind(&done); |
| 492 } else { | 492 } else { |
| 493 ArrayNArgumentsConstructorStub stub(isolate(), kind, override_mode); | 493 ArrayNArgumentsConstructorStub stub(isolate(), kind, override_mode); |
| 494 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr); | 494 CallCode(stub.GetCode(), RelocInfo::CONSTRUCT_CALL, instr); |
| 495 } | 495 } |
| 496 | 496 |
| 497 ASSERT(ToRegister(instr->result()).is(x0)); | 497 ASSERT(ToRegister(instr->result()).is(x0)); |
| 498 } | 498 } |
| 499 | 499 |
| 500 | 500 |
| 501 void LCodeGen::CallRuntime(const Runtime::Function* function, | 501 void LCodeGen::CallRuntime(const Runtime::Function* function, |
| 502 int num_arguments, | 502 int num_arguments, |
| 503 LInstruction* instr, | 503 LInstruction* instr, |
| 504 SaveFPRegsMode save_doubles) { | 504 SaveFPRegsMode save_doubles) { |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1734 } | 1734 } |
| 1735 | 1735 |
| 1736 | 1736 |
| 1737 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { | 1737 void LCodeGen::DoArithmeticT(LArithmeticT* instr) { |
| 1738 ASSERT(ToRegister(instr->context()).is(cp)); | 1738 ASSERT(ToRegister(instr->context()).is(cp)); |
| 1739 ASSERT(ToRegister(instr->left()).is(x1)); | 1739 ASSERT(ToRegister(instr->left()).is(x1)); |
| 1740 ASSERT(ToRegister(instr->right()).is(x0)); | 1740 ASSERT(ToRegister(instr->right()).is(x0)); |
| 1741 ASSERT(ToRegister(instr->result()).is(x0)); | 1741 ASSERT(ToRegister(instr->result()).is(x0)); |
| 1742 | 1742 |
| 1743 BinaryOpICStub stub(isolate(), instr->op(), NO_OVERWRITE); | 1743 BinaryOpICStub stub(isolate(), instr->op(), NO_OVERWRITE); |
| 1744 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 1744 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 1745 } | 1745 } |
| 1746 | 1746 |
| 1747 | 1747 |
| 1748 void LCodeGen::DoBitI(LBitI* instr) { | 1748 void LCodeGen::DoBitI(LBitI* instr) { |
| 1749 Register result = ToRegister32(instr->result()); | 1749 Register result = ToRegister32(instr->result()); |
| 1750 Register left = ToRegister32(instr->left()); | 1750 Register left = ToRegister32(instr->left()); |
| 1751 Operand right = ToOperand32U(instr->right()); | 1751 Operand right = ToOperand32U(instr->right()); |
| 1752 | 1752 |
| 1753 switch (instr->op()) { | 1753 switch (instr->op()) { |
| 1754 case Token::BIT_AND: __ And(result, left, right); break; | 1754 case Token::BIT_AND: __ And(result, left, right); break; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2045 CallRuntime(instr->function(), instr->arity(), instr); | 2045 CallRuntime(instr->function(), instr->arity(), instr); |
| 2046 } | 2046 } |
| 2047 | 2047 |
| 2048 | 2048 |
| 2049 void LCodeGen::DoCallStub(LCallStub* instr) { | 2049 void LCodeGen::DoCallStub(LCallStub* instr) { |
| 2050 ASSERT(ToRegister(instr->context()).is(cp)); | 2050 ASSERT(ToRegister(instr->context()).is(cp)); |
| 2051 ASSERT(ToRegister(instr->result()).is(x0)); | 2051 ASSERT(ToRegister(instr->result()).is(x0)); |
| 2052 switch (instr->hydrogen()->major_key()) { | 2052 switch (instr->hydrogen()->major_key()) { |
| 2053 case CodeStub::RegExpExec: { | 2053 case CodeStub::RegExpExec: { |
| 2054 RegExpExecStub stub(isolate()); | 2054 RegExpExecStub stub(isolate()); |
| 2055 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 2055 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 2056 break; | 2056 break; |
| 2057 } | 2057 } |
| 2058 case CodeStub::SubString: { | 2058 case CodeStub::SubString: { |
| 2059 SubStringStub stub(isolate()); | 2059 SubStringStub stub(isolate()); |
| 2060 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 2060 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 2061 break; | 2061 break; |
| 2062 } | 2062 } |
| 2063 case CodeStub::StringCompare: { | 2063 case CodeStub::StringCompare: { |
| 2064 StringCompareStub stub(isolate()); | 2064 StringCompareStub stub(isolate()); |
| 2065 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 2065 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 2066 break; | 2066 break; |
| 2067 } | 2067 } |
| 2068 default: | 2068 default: |
| 2069 UNREACHABLE(); | 2069 UNREACHABLE(); |
| 2070 } | 2070 } |
| 2071 } | 2071 } |
| 2072 | 2072 |
| 2073 | 2073 |
| 2074 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { | 2074 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) { |
| 2075 GenerateOsrPrologue(); | 2075 GenerateOsrPrologue(); |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2787 ASSERT(instr->IsMarkedAsCall()); | 2787 ASSERT(instr->IsMarkedAsCall()); |
| 2788 | 2788 |
| 2789 // Use the fast case closure allocation code that allocates in new | 2789 // Use the fast case closure allocation code that allocates in new |
| 2790 // space for nested functions that don't need literals cloning. | 2790 // space for nested functions that don't need literals cloning. |
| 2791 bool pretenure = instr->hydrogen()->pretenure(); | 2791 bool pretenure = instr->hydrogen()->pretenure(); |
| 2792 if (!pretenure && instr->hydrogen()->has_no_literals()) { | 2792 if (!pretenure && instr->hydrogen()->has_no_literals()) { |
| 2793 FastNewClosureStub stub(isolate(), | 2793 FastNewClosureStub stub(isolate(), |
| 2794 instr->hydrogen()->strict_mode(), | 2794 instr->hydrogen()->strict_mode(), |
| 2795 instr->hydrogen()->is_generator()); | 2795 instr->hydrogen()->is_generator()); |
| 2796 __ Mov(x2, Operand(instr->hydrogen()->shared_info())); | 2796 __ Mov(x2, Operand(instr->hydrogen()->shared_info())); |
| 2797 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 2797 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 2798 } else { | 2798 } else { |
| 2799 __ Mov(x2, Operand(instr->hydrogen()->shared_info())); | 2799 __ Mov(x2, Operand(instr->hydrogen()->shared_info())); |
| 2800 __ Mov(x1, Operand(pretenure ? factory()->true_value() | 2800 __ Mov(x1, Operand(pretenure ? factory()->true_value() |
| 2801 : factory()->false_value())); | 2801 : factory()->false_value())); |
| 2802 __ Push(cp, x2, x1); | 2802 __ Push(cp, x2, x1); |
| 2803 CallRuntime(Runtime::kHiddenNewClosure, 3, instr); | 2803 CallRuntime(Runtime::kHiddenNewClosure, 3, instr); |
| 2804 } | 2804 } |
| 2805 } | 2805 } |
| 2806 | 2806 |
| 2807 | 2807 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2960 } | 2960 } |
| 2961 | 2961 |
| 2962 | 2962 |
| 2963 void LCodeGen::DoInstanceOf(LInstanceOf* instr) { | 2963 void LCodeGen::DoInstanceOf(LInstanceOf* instr) { |
| 2964 ASSERT(ToRegister(instr->context()).is(cp)); | 2964 ASSERT(ToRegister(instr->context()).is(cp)); |
| 2965 // Assert that the arguments are in the registers expected by InstanceofStub. | 2965 // Assert that the arguments are in the registers expected by InstanceofStub. |
| 2966 ASSERT(ToRegister(instr->left()).Is(InstanceofStub::left())); | 2966 ASSERT(ToRegister(instr->left()).Is(InstanceofStub::left())); |
| 2967 ASSERT(ToRegister(instr->right()).Is(InstanceofStub::right())); | 2967 ASSERT(ToRegister(instr->right()).Is(InstanceofStub::right())); |
| 2968 | 2968 |
| 2969 InstanceofStub stub(isolate(), InstanceofStub::kArgsInRegisters); | 2969 InstanceofStub stub(isolate(), InstanceofStub::kArgsInRegisters); |
| 2970 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 2970 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 2971 | 2971 |
| 2972 // InstanceofStub returns a result in x0: | 2972 // InstanceofStub returns a result in x0: |
| 2973 // 0 => not an instance | 2973 // 0 => not an instance |
| 2974 // smi 1 => instance. | 2974 // smi 1 => instance. |
| 2975 __ Cmp(x0, 0); | 2975 __ Cmp(x0, 0); |
| 2976 __ LoadTrueFalseRoots(x0, x1); | 2976 __ LoadTrueFalseRoots(x0, x1); |
| 2977 __ Csel(x0, x0, x1, eq); | 2977 __ Csel(x0, x0, x1, eq); |
| 2978 } | 2978 } |
| 2979 | 2979 |
| 2980 | 2980 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3075 flags | InstanceofStub::kCallSiteInlineCheck); | 3075 flags | InstanceofStub::kCallSiteInlineCheck); |
| 3076 | 3076 |
| 3077 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); | 3077 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); |
| 3078 LoadContextFromDeferred(instr->context()); | 3078 LoadContextFromDeferred(instr->context()); |
| 3079 | 3079 |
| 3080 // Prepare InstanceofStub arguments. | 3080 // Prepare InstanceofStub arguments. |
| 3081 ASSERT(ToRegister(instr->value()).Is(InstanceofStub::left())); | 3081 ASSERT(ToRegister(instr->value()).Is(InstanceofStub::left())); |
| 3082 __ LoadObject(InstanceofStub::right(), instr->function()); | 3082 __ LoadObject(InstanceofStub::right(), instr->function()); |
| 3083 | 3083 |
| 3084 InstanceofStub stub(isolate(), flags); | 3084 InstanceofStub stub(isolate(), flags); |
| 3085 CallCodeGeneric(stub.GetCode(isolate()), | 3085 CallCodeGeneric(stub.GetCode(), |
| 3086 RelocInfo::CODE_TARGET, | 3086 RelocInfo::CODE_TARGET, |
| 3087 instr, | 3087 instr, |
| 3088 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); | 3088 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
| 3089 LEnvironment* env = instr->GetDeferredLazyDeoptimizationEnvironment(); | 3089 LEnvironment* env = instr->GetDeferredLazyDeoptimizationEnvironment(); |
| 3090 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); | 3090 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
| 3091 | 3091 |
| 3092 // Put the result value into the result register slot. | 3092 // Put the result value into the result register slot. |
| 3093 __ StoreToSafepointRegisterSlot(result, result); | 3093 __ StoreToSafepointRegisterSlot(result, result); |
| 3094 } | 3094 } |
| 3095 | 3095 |
| (...skipping 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5311 } | 5311 } |
| 5312 | 5312 |
| 5313 | 5313 |
| 5314 void LCodeGen::DoStringAdd(LStringAdd* instr) { | 5314 void LCodeGen::DoStringAdd(LStringAdd* instr) { |
| 5315 ASSERT(ToRegister(instr->context()).is(cp)); | 5315 ASSERT(ToRegister(instr->context()).is(cp)); |
| 5316 ASSERT(ToRegister(instr->left()).Is(x1)); | 5316 ASSERT(ToRegister(instr->left()).Is(x1)); |
| 5317 ASSERT(ToRegister(instr->right()).Is(x0)); | 5317 ASSERT(ToRegister(instr->right()).Is(x0)); |
| 5318 StringAddStub stub(isolate(), | 5318 StringAddStub stub(isolate(), |
| 5319 instr->hydrogen()->flags(), | 5319 instr->hydrogen()->flags(), |
| 5320 instr->hydrogen()->pretenure_flag()); | 5320 instr->hydrogen()->pretenure_flag()); |
| 5321 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 5321 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
| 5322 } | 5322 } |
| 5323 | 5323 |
| 5324 | 5324 |
| 5325 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { | 5325 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) { |
| 5326 class DeferredStringCharCodeAt: public LDeferredCode { | 5326 class DeferredStringCharCodeAt: public LDeferredCode { |
| 5327 public: | 5327 public: |
| 5328 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) | 5328 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr) |
| 5329 : LDeferredCode(codegen), instr_(instr) { } | 5329 : LDeferredCode(codegen), instr_(instr) { } |
| 5330 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } | 5330 virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); } |
| 5331 virtual LInstruction* instr() { return instr_; } | 5331 virtual LInstruction* instr() { return instr_; } |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5899 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 5899 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
| 5900 // Index is equal to negated out of object property index plus 1. | 5900 // Index is equal to negated out of object property index plus 1. |
| 5901 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 5901 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
| 5902 __ Ldr(result, FieldMemOperand(result, | 5902 __ Ldr(result, FieldMemOperand(result, |
| 5903 FixedArray::kHeaderSize - kPointerSize)); | 5903 FixedArray::kHeaderSize - kPointerSize)); |
| 5904 __ Bind(deferred->exit()); | 5904 __ Bind(deferred->exit()); |
| 5905 __ Bind(&done); | 5905 __ Bind(&done); |
| 5906 } | 5906 } |
| 5907 | 5907 |
| 5908 } } // namespace v8::internal | 5908 } } // namespace v8::internal |
| OLD | NEW |