| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 namespace v8 { | 40 namespace v8 { |
| 41 namespace internal { | 41 namespace internal { |
| 42 | 42 |
| 43 // ------------------------------------------------------------------------- | 43 // ------------------------------------------------------------------------- |
| 44 // MacroAssembler implementation. | 44 // MacroAssembler implementation. |
| 45 | 45 |
| 46 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) | 46 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size) |
| 47 : Assembler(arg_isolate, buffer, size), | 47 : Assembler(arg_isolate, buffer, size), |
| 48 generating_stub_(false), | 48 generating_stub_(false), |
| 49 allow_stub_calls_(true), | |
| 50 has_frame_(false) { | 49 has_frame_(false) { |
| 51 if (isolate() != NULL) { | 50 if (isolate() != NULL) { |
| 52 // TODO(titzer): should we just use a null handle here instead? | 51 // TODO(titzer): should we just use a null handle here instead? |
| 53 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), | 52 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), |
| 54 isolate()); | 53 isolate()); |
| 55 } | 54 } |
| 56 } | 55 } |
| 57 | 56 |
| 58 | 57 |
| 59 void MacroAssembler::Load(Register dst, const Operand& src, Representation r) { | 58 void MacroAssembler::Load(Register dst, const Operand& src, Representation r) { |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 | 606 |
| 608 ASSERT(!object.is(value)); | 607 ASSERT(!object.is(value)); |
| 609 ASSERT(!object.is(address)); | 608 ASSERT(!object.is(address)); |
| 610 ASSERT(!value.is(address)); | 609 ASSERT(!value.is(address)); |
| 611 AssertNotSmi(object); | 610 AssertNotSmi(object); |
| 612 | 611 |
| 613 if (!FLAG_incremental_marking) { | 612 if (!FLAG_incremental_marking) { |
| 614 return; | 613 return; |
| 615 } | 614 } |
| 616 | 615 |
| 616 // Count number of write barriers in generated code. |
| 617 isolate()->counters()->write_barriers_static()->Increment(); |
| 618 IncrementCounter(isolate()->counters()->write_barriers_dynamic(), 1); |
| 619 |
| 617 // A single check of the map's pages interesting flag suffices, since it is | 620 // A single check of the map's pages interesting flag suffices, since it is |
| 618 // only set during incremental collection, and then it's also guaranteed that | 621 // only set during incremental collection, and then it's also guaranteed that |
| 619 // the from object's page's interesting flag is also set. This optimization | 622 // the from object's page's interesting flag is also set. This optimization |
| 620 // relies on the fact that maps can never be in new space. | 623 // relies on the fact that maps can never be in new space. |
| 621 ASSERT(!isolate()->heap()->InNewSpace(*map)); | 624 ASSERT(!isolate()->heap()->InNewSpace(*map)); |
| 622 CheckPageFlagForMap(map, | 625 CheckPageFlagForMap(map, |
| 623 MemoryChunk::kPointersToHereAreInterestingMask, | 626 MemoryChunk::kPointersToHereAreInterestingMask, |
| 624 zero, | 627 zero, |
| 625 &done, | 628 &done, |
| 626 Label::kNear); | 629 Label::kNear); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 } | 666 } |
| 664 | 667 |
| 665 if (emit_debug_code()) { | 668 if (emit_debug_code()) { |
| 666 Label ok; | 669 Label ok; |
| 667 cmp(value, Operand(address, 0)); | 670 cmp(value, Operand(address, 0)); |
| 668 j(equal, &ok, Label::kNear); | 671 j(equal, &ok, Label::kNear); |
| 669 int3(); | 672 int3(); |
| 670 bind(&ok); | 673 bind(&ok); |
| 671 } | 674 } |
| 672 | 675 |
| 676 // Count number of write barriers in generated code. |
| 677 isolate()->counters()->write_barriers_static()->Increment(); |
| 678 IncrementCounter(isolate()->counters()->write_barriers_dynamic(), 1); |
| 679 |
| 673 // First, check if a write barrier is even needed. The tests below | 680 // First, check if a write barrier is even needed. The tests below |
| 674 // catch stores of Smis and stores into young gen. | 681 // catch stores of Smis and stores into young gen. |
| 675 Label done; | 682 Label done; |
| 676 | 683 |
| 677 if (smi_check == INLINE_SMI_CHECK) { | 684 if (smi_check == INLINE_SMI_CHECK) { |
| 678 // Skip barrier if writing a smi. | 685 // Skip barrier if writing a smi. |
| 679 JumpIfSmi(value, &done, Label::kNear); | 686 JumpIfSmi(value, &done, Label::kNear); |
| 680 } | 687 } |
| 681 | 688 |
| 682 CheckPageFlag(value, | 689 CheckPageFlag(value, |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 ASSERT(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize); | 1099 ASSERT(ExitFrameConstants::kCallerFPOffset == 0 * kPointerSize); |
| 1093 push(ebp); | 1100 push(ebp); |
| 1094 mov(ebp, esp); | 1101 mov(ebp, esp); |
| 1095 | 1102 |
| 1096 // Reserve room for entry stack pointer and push the code object. | 1103 // Reserve room for entry stack pointer and push the code object. |
| 1097 ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize); | 1104 ASSERT(ExitFrameConstants::kSPOffset == -1 * kPointerSize); |
| 1098 push(Immediate(0)); // Saved entry sp, patched before call. | 1105 push(Immediate(0)); // Saved entry sp, patched before call. |
| 1099 push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. | 1106 push(Immediate(CodeObject())); // Accessed from ExitFrame::code_slot. |
| 1100 | 1107 |
| 1101 // Save the frame pointer and the context in top. | 1108 // Save the frame pointer and the context in top. |
| 1102 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, | 1109 ExternalReference c_entry_fp_address(Isolate::kCEntryFPAddress, isolate()); |
| 1103 isolate()); | 1110 ExternalReference context_address(Isolate::kContextAddress, isolate()); |
| 1104 ExternalReference context_address(Isolate::kContextAddress, | |
| 1105 isolate()); | |
| 1106 mov(Operand::StaticVariable(c_entry_fp_address), ebp); | 1111 mov(Operand::StaticVariable(c_entry_fp_address), ebp); |
| 1107 mov(Operand::StaticVariable(context_address), esi); | 1112 mov(Operand::StaticVariable(context_address), esi); |
| 1108 } | 1113 } |
| 1109 | 1114 |
| 1110 | 1115 |
| 1111 void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) { | 1116 void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) { |
| 1112 // Optionally save all XMM registers. | 1117 // Optionally save all XMM registers. |
| 1113 if (save_doubles) { | 1118 if (save_doubles) { |
| 1114 CpuFeatureScope scope(this, SSE2); | 1119 CpuFeatureScope scope(this, SSE2); |
| 1115 int space = XMMRegister::kNumRegisters * kDoubleSize + argc * kPointerSize; | 1120 int space = XMMRegister::kNumRegisters * kDoubleSize + argc * kPointerSize; |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 } | 2180 } |
| 2176 | 2181 |
| 2177 | 2182 |
| 2178 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { | 2183 void MacroAssembler::CallStub(CodeStub* stub, TypeFeedbackId ast_id) { |
| 2179 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. | 2184 ASSERT(AllowThisStubCall(stub)); // Calls are not allowed in some stubs. |
| 2180 call(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, ast_id); | 2185 call(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, ast_id); |
| 2181 } | 2186 } |
| 2182 | 2187 |
| 2183 | 2188 |
| 2184 void MacroAssembler::TailCallStub(CodeStub* stub) { | 2189 void MacroAssembler::TailCallStub(CodeStub* stub) { |
| 2185 ASSERT(allow_stub_calls_ || | |
| 2186 stub->CompilingCallsToThisStubIsGCSafe(isolate())); | |
| 2187 jmp(stub->GetCode(isolate()), RelocInfo::CODE_TARGET); | 2190 jmp(stub->GetCode(isolate()), RelocInfo::CODE_TARGET); |
| 2188 } | 2191 } |
| 2189 | 2192 |
| 2190 | 2193 |
| 2191 void MacroAssembler::StubReturn(int argc) { | 2194 void MacroAssembler::StubReturn(int argc) { |
| 2192 ASSERT(argc >= 1 && generating_stub()); | 2195 ASSERT(argc >= 1 && generating_stub()); |
| 2193 ret((argc - 1) * kPointerSize); | 2196 ret((argc - 1) * kPointerSize); |
| 2194 } | 2197 } |
| 2195 | 2198 |
| 2196 | 2199 |
| 2197 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) { | 2200 bool MacroAssembler::AllowThisStubCall(CodeStub* stub) { |
| 2198 if (!has_frame_ && stub->SometimesSetsUpAFrame()) return false; | 2201 return has_frame_ || !stub->SometimesSetsUpAFrame(); |
| 2199 return allow_stub_calls_ || stub->CompilingCallsToThisStubIsGCSafe(isolate()); | |
| 2200 } | 2202 } |
| 2201 | 2203 |
| 2202 | 2204 |
| 2203 void MacroAssembler::IllegalOperation(int num_arguments) { | 2205 void MacroAssembler::IllegalOperation(int num_arguments) { |
| 2204 if (num_arguments > 0) { | 2206 if (num_arguments > 0) { |
| 2205 add(esp, Immediate(num_arguments * kPointerSize)); | 2207 add(esp, Immediate(num_arguments * kPointerSize)); |
| 2206 } | 2208 } |
| 2207 mov(eax, Immediate(isolate()->factory()->undefined_value())); | 2209 mov(eax, Immediate(isolate()->factory()->undefined_value())); |
| 2208 } | 2210 } |
| 2209 | 2211 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 2623 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
| 2622 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); | 2624 mov(ebx, FieldOperand(edx, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 2623 SmiUntag(ebx); | 2625 SmiUntag(ebx); |
| 2624 | 2626 |
| 2625 ParameterCount expected(ebx); | 2627 ParameterCount expected(ebx); |
| 2626 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 2628 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
| 2627 expected, actual, flag, call_wrapper, call_kind); | 2629 expected, actual, flag, call_wrapper, call_kind); |
| 2628 } | 2630 } |
| 2629 | 2631 |
| 2630 | 2632 |
| 2631 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, | 2633 void MacroAssembler::InvokeFunction(Register fun, |
| 2632 const ParameterCount& expected, | 2634 const ParameterCount& expected, |
| 2633 const ParameterCount& actual, | 2635 const ParameterCount& actual, |
| 2634 InvokeFlag flag, | 2636 InvokeFlag flag, |
| 2635 const CallWrapper& call_wrapper, | 2637 const CallWrapper& call_wrapper, |
| 2636 CallKind call_kind) { | 2638 CallKind call_kind) { |
| 2637 // You can't call a function without a valid frame. | 2639 // You can't call a function without a valid frame. |
| 2638 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 2640 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
| 2639 | 2641 |
| 2640 // Get the function and setup the context. | 2642 ASSERT(fun.is(edi)); |
| 2641 LoadHeapObject(edi, function); | |
| 2642 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 2643 mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
| 2643 | 2644 |
| 2644 // We call indirectly through the code field in the function to | |
| 2645 // allow recompilation to take effect without changing any of the | |
| 2646 // call sites. | |
| 2647 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), | 2645 InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset), |
| 2648 expected, actual, flag, call_wrapper, call_kind); | 2646 expected, actual, flag, call_wrapper, call_kind); |
| 2649 } | 2647 } |
| 2650 | 2648 |
| 2651 | 2649 |
| 2650 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, |
| 2651 const ParameterCount& expected, |
| 2652 const ParameterCount& actual, |
| 2653 InvokeFlag flag, |
| 2654 const CallWrapper& call_wrapper, |
| 2655 CallKind call_kind) { |
| 2656 LoadHeapObject(edi, function); |
| 2657 InvokeFunction(edi, expected, actual, flag, call_wrapper, call_kind); |
| 2658 } |
| 2659 |
| 2660 |
| 2652 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, | 2661 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, |
| 2653 InvokeFlag flag, | 2662 InvokeFlag flag, |
| 2654 const CallWrapper& call_wrapper) { | 2663 const CallWrapper& call_wrapper) { |
| 2655 // You can't call a builtin without a valid frame. | 2664 // You can't call a builtin without a valid frame. |
| 2656 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 2665 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
| 2657 | 2666 |
| 2658 // Rely on the assertion to check that the number of provided | 2667 // Rely on the assertion to check that the number of provided |
| 2659 // arguments match the expected number of arguments. Fake a | 2668 // arguments match the expected number of arguments. Fake a |
| 2660 // parameter count to avoid emitting code to do the check. | 2669 // parameter count to avoid emitting code to do the check. |
| 2661 ParameterCount expected(0); | 2670 ParameterCount expected(0); |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3685 cmp(scratch1, Immediate(DICTIONARY_ELEMENTS)); | 3694 cmp(scratch1, Immediate(DICTIONARY_ELEMENTS)); |
| 3686 j(equal, found); | 3695 j(equal, found); |
| 3687 mov(current, FieldOperand(current, Map::kPrototypeOffset)); | 3696 mov(current, FieldOperand(current, Map::kPrototypeOffset)); |
| 3688 cmp(current, Immediate(factory->null_value())); | 3697 cmp(current, Immediate(factory->null_value())); |
| 3689 j(not_equal, &loop_again); | 3698 j(not_equal, &loop_again); |
| 3690 } | 3699 } |
| 3691 | 3700 |
| 3692 } } // namespace v8::internal | 3701 } } // namespace v8::internal |
| 3693 | 3702 |
| 3694 #endif // V8_TARGET_ARCH_IA32 | 3703 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |