OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 25 matching lines...) Expand all Loading... |
36 namespace v8 { | 36 namespace v8 { |
37 namespace internal { | 37 namespace internal { |
38 | 38 |
39 | 39 |
40 // When invoking builtins, we need to record the safepoint in the middle of | 40 // When invoking builtins, we need to record the safepoint in the middle of |
41 // the invoke instruction sequence generated by the macro assembler. | 41 // the invoke instruction sequence generated by the macro assembler. |
42 class SafepointGenerator : public PostCallGenerator { | 42 class SafepointGenerator : public PostCallGenerator { |
43 public: | 43 public: |
44 SafepointGenerator(LCodeGen* codegen, | 44 SafepointGenerator(LCodeGen* codegen, |
45 LPointerMap* pointers, | 45 LPointerMap* pointers, |
46 int deoptimization_index) | 46 int deoptimization_index, |
| 47 bool ensure_reloc_space = false) |
47 : codegen_(codegen), | 48 : codegen_(codegen), |
48 pointers_(pointers), | 49 pointers_(pointers), |
49 deoptimization_index_(deoptimization_index) { } | 50 deoptimization_index_(deoptimization_index), |
| 51 ensure_reloc_space_(ensure_reloc_space) { } |
50 virtual ~SafepointGenerator() { } | 52 virtual ~SafepointGenerator() { } |
51 | 53 |
52 virtual void Generate() { | 54 virtual void Generate() { |
| 55 // Ensure that we have enough space in the reloc info to patch |
| 56 // this with calls when doing deoptimization. |
| 57 if (ensure_reloc_space_) { |
| 58 codegen_->masm()->RecordComment(RelocInfo::kFillerCommentString, true); |
| 59 } |
53 codegen_->RecordSafepoint(pointers_, deoptimization_index_); | 60 codegen_->RecordSafepoint(pointers_, deoptimization_index_); |
54 } | 61 } |
55 | 62 |
56 private: | 63 private: |
57 LCodeGen* codegen_; | 64 LCodeGen* codegen_; |
58 LPointerMap* pointers_; | 65 LPointerMap* pointers_; |
59 int deoptimization_index_; | 66 int deoptimization_index_; |
| 67 bool ensure_reloc_space_; |
60 }; | 68 }; |
61 | 69 |
62 | 70 |
63 #define __ masm()-> | 71 #define __ masm()-> |
64 | 72 |
65 bool LCodeGen::GenerateCode() { | 73 bool LCodeGen::GenerateCode() { |
66 HPhase phase("Code generation", chunk()); | 74 HPhase phase("Code generation", chunk()); |
67 ASSERT(is_unused()); | 75 ASSERT(is_unused()); |
68 status_ = GENERATING; | 76 status_ = GENERATING; |
69 CpuFeatures::Scope scope(SSE2); | 77 CpuFeatures::Scope scope(SSE2); |
(...skipping 2144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2214 | 2222 |
2215 // Invoke the function. | 2223 // Invoke the function. |
2216 __ bind(&invoke); | 2224 __ bind(&invoke); |
2217 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); | 2225 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
2218 LPointerMap* pointers = instr->pointer_map(); | 2226 LPointerMap* pointers = instr->pointer_map(); |
2219 LEnvironment* env = instr->deoptimization_environment(); | 2227 LEnvironment* env = instr->deoptimization_environment(); |
2220 RecordPosition(pointers->position()); | 2228 RecordPosition(pointers->position()); |
2221 RegisterEnvironmentForDeoptimization(env); | 2229 RegisterEnvironmentForDeoptimization(env); |
2222 SafepointGenerator safepoint_generator(this, | 2230 SafepointGenerator safepoint_generator(this, |
2223 pointers, | 2231 pointers, |
2224 env->deoptimization_index()); | 2232 env->deoptimization_index(), |
| 2233 true); |
2225 v8::internal::ParameterCount actual(eax); | 2234 v8::internal::ParameterCount actual(eax); |
2226 __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator); | 2235 __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator); |
2227 } | 2236 } |
2228 | 2237 |
2229 | 2238 |
2230 void LCodeGen::DoPushArgument(LPushArgument* instr) { | 2239 void LCodeGen::DoPushArgument(LPushArgument* instr) { |
2231 LOperand* argument = instr->InputAt(0); | 2240 LOperand* argument = instr->InputAt(0); |
2232 if (argument->IsConstantOperand()) { | 2241 if (argument->IsConstantOperand()) { |
2233 __ push(ToImmediate(argument)); | 2242 __ push(ToImmediate(argument)); |
2234 } else { | 2243 } else { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2285 __ mov(eax, arity); | 2294 __ mov(eax, arity); |
2286 } | 2295 } |
2287 | 2296 |
2288 LPointerMap* pointers = instr->pointer_map(); | 2297 LPointerMap* pointers = instr->pointer_map(); |
2289 RecordPosition(pointers->position()); | 2298 RecordPosition(pointers->position()); |
2290 | 2299 |
2291 // Invoke function. | 2300 // Invoke function. |
2292 if (*function == *graph()->info()->closure()) { | 2301 if (*function == *graph()->info()->closure()) { |
2293 __ CallSelf(); | 2302 __ CallSelf(); |
2294 } else { | 2303 } else { |
| 2304 // This is an indirect call and will not be recorded in the reloc info. |
| 2305 // Add a comment to the reloc info in case we need to patch this during |
| 2306 // deoptimization. |
| 2307 __ RecordComment(RelocInfo::kFillerCommentString, true); |
2295 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset)); | 2308 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset)); |
2296 } | 2309 } |
2297 | 2310 |
2298 // Setup deoptimization. | 2311 // Setup deoptimization. |
2299 RegisterLazyDeoptimization(instr); | 2312 RegisterLazyDeoptimization(instr); |
2300 } | 2313 } |
2301 | 2314 |
2302 | 2315 |
2303 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { | 2316 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { |
2304 ASSERT(ToRegister(instr->result()).is(eax)); | 2317 ASSERT(ToRegister(instr->result()).is(eax)); |
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3724 if (key->IsConstantOperand()) { | 3737 if (key->IsConstantOperand()) { |
3725 __ push(ToImmediate(key)); | 3738 __ push(ToImmediate(key)); |
3726 } else { | 3739 } else { |
3727 __ push(ToOperand(key)); | 3740 __ push(ToOperand(key)); |
3728 } | 3741 } |
3729 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); | 3742 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
3730 LPointerMap* pointers = instr->pointer_map(); | 3743 LPointerMap* pointers = instr->pointer_map(); |
3731 LEnvironment* env = instr->deoptimization_environment(); | 3744 LEnvironment* env = instr->deoptimization_environment(); |
3732 RecordPosition(pointers->position()); | 3745 RecordPosition(pointers->position()); |
3733 RegisterEnvironmentForDeoptimization(env); | 3746 RegisterEnvironmentForDeoptimization(env); |
| 3747 // Create safepoint generator that will also ensure enough space in the |
| 3748 // reloc info for patching in deoptimization (since this is invoking a |
| 3749 // builtin) |
3734 SafepointGenerator safepoint_generator(this, | 3750 SafepointGenerator safepoint_generator(this, |
3735 pointers, | 3751 pointers, |
3736 env->deoptimization_index()); | 3752 env->deoptimization_index(), |
| 3753 true); |
3737 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3754 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
3738 __ push(Immediate(Smi::FromInt(strict_mode_flag()))); | 3755 __ push(Immediate(Smi::FromInt(strict_mode_flag()))); |
3739 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator); | 3756 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator); |
3740 } | 3757 } |
3741 | 3758 |
3742 | 3759 |
3743 void LCodeGen::DoStackCheck(LStackCheck* instr) { | 3760 void LCodeGen::DoStackCheck(LStackCheck* instr) { |
3744 // Perform stack overflow check. | 3761 // Perform stack overflow check. |
3745 NearLabel done; | 3762 NearLabel done; |
3746 ExternalReference stack_limit = ExternalReference::address_of_stack_limit(); | 3763 ExternalReference stack_limit = ExternalReference::address_of_stack_limit(); |
(...skipping 21 matching lines...) Expand all Loading... |
3768 ASSERT(osr_pc_offset_ == -1); | 3785 ASSERT(osr_pc_offset_ == -1); |
3769 osr_pc_offset_ = masm()->pc_offset(); | 3786 osr_pc_offset_ = masm()->pc_offset(); |
3770 } | 3787 } |
3771 | 3788 |
3772 | 3789 |
3773 #undef __ | 3790 #undef __ |
3774 | 3791 |
3775 } } // namespace v8::internal | 3792 } } // namespace v8::internal |
3776 | 3793 |
3777 #endif // V8_TARGET_ARCH_IA32 | 3794 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |