Chromium Code Reviews| 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 PrintF("--------------------GEEEEEEE-------------------\n"); | |
|
Mads Ager (chromium)
2011/02/16 07:26:12
Remove please.
Rico
2011/02/16 07:31:13
Done.
| |
| 58 if (ensure_reloc_space_) { | |
| 59 PrintF("--------------------FILLING-------------------\n"); | |
|
Mads Ager (chromium)
2011/02/16 07:26:12
Remove please.
Rico
2011/02/16 07:31:13
Done.
| |
| 60 codegen_->masm()->RecordComment(RelocInfo::kFillerCommentString, true); | |
| 61 } | |
| 53 codegen_->RecordSafepoint(pointers_, deoptimization_index_); | 62 codegen_->RecordSafepoint(pointers_, deoptimization_index_); |
| 54 } | 63 } |
| 55 | 64 |
| 56 private: | 65 private: |
| 57 LCodeGen* codegen_; | 66 LCodeGen* codegen_; |
| 58 LPointerMap* pointers_; | 67 LPointerMap* pointers_; |
| 59 int deoptimization_index_; | 68 int deoptimization_index_; |
| 69 bool ensure_reloc_space_; | |
| 60 }; | 70 }; |
| 61 | 71 |
| 62 | 72 |
| 63 #define __ masm()-> | 73 #define __ masm()-> |
| 64 | 74 |
| 65 bool LCodeGen::GenerateCode() { | 75 bool LCodeGen::GenerateCode() { |
| 66 HPhase phase("Code generation", chunk()); | 76 HPhase phase("Code generation", chunk()); |
| 67 ASSERT(is_unused()); | 77 ASSERT(is_unused()); |
| 68 status_ = GENERATING; | 78 status_ = GENERATING; |
| 69 CpuFeatures::Scope scope(SSE2); | 79 CpuFeatures::Scope scope(SSE2); |
| 70 return GeneratePrologue() && | 80 return GeneratePrologue() && |
| 71 GenerateBody() && | 81 GenerateBody() && |
| 72 GenerateDeferredCode() && | 82 GenerateDeferredCode() && |
| 73 GenerateSafepointTable(); | 83 GenerateSafepointTable(); |
| 74 } | 84 } |
| 75 | 85 |
| 76 | 86 |
| 77 void LCodeGen::FinishCode(Handle<Code> code) { | 87 void LCodeGen::FinishCode(Handle<Code> code) { |
| 78 ASSERT(is_done()); | 88 ASSERT(is_done()); |
| 79 code->set_stack_slots(StackSlotCount()); | 89 code->set_stack_slots(StackSlotCount()); |
| 80 code->set_safepoint_table_start(safepoints_.GetCodeOffset()); | 90 code->set_safepoint_table_offset(safepoints_.GetCodeOffset()); |
| 81 PopulateDeoptimizationData(code); | 91 PopulateDeoptimizationData(code); |
| 82 } | 92 } |
| 83 | 93 |
| 84 | 94 |
| 85 void LCodeGen::Abort(const char* format, ...) { | 95 void LCodeGen::Abort(const char* format, ...) { |
| 86 if (FLAG_trace_bailout) { | 96 if (FLAG_trace_bailout) { |
| 87 SmartPointer<char> debug_name = graph()->debug_name()->ToCString(); | 97 SmartPointer<char> debug_name = graph()->debug_name()->ToCString(); |
| 88 PrintF("Aborting LCodeGen in @\"%s\": ", *debug_name); | 98 PrintF("Aborting LCodeGen in @\"%s\": ", *debug_name); |
| 89 va_list arguments; | 99 va_list arguments; |
| 90 va_start(arguments, format); | 100 va_start(arguments, format); |
| (...skipping 2048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2139 | 2149 |
| 2140 // Invoke the function. | 2150 // Invoke the function. |
| 2141 __ bind(&invoke); | 2151 __ bind(&invoke); |
| 2142 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); | 2152 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
| 2143 LPointerMap* pointers = instr->pointer_map(); | 2153 LPointerMap* pointers = instr->pointer_map(); |
| 2144 LEnvironment* env = instr->deoptimization_environment(); | 2154 LEnvironment* env = instr->deoptimization_environment(); |
| 2145 RecordPosition(pointers->position()); | 2155 RecordPosition(pointers->position()); |
| 2146 RegisterEnvironmentForDeoptimization(env); | 2156 RegisterEnvironmentForDeoptimization(env); |
| 2147 SafepointGenerator safepoint_generator(this, | 2157 SafepointGenerator safepoint_generator(this, |
| 2148 pointers, | 2158 pointers, |
| 2149 env->deoptimization_index()); | 2159 env->deoptimization_index(), |
| 2160 true); | |
| 2150 ASSERT(receiver.is(eax)); | 2161 ASSERT(receiver.is(eax)); |
| 2151 v8::internal::ParameterCount actual(eax); | 2162 v8::internal::ParameterCount actual(eax); |
| 2152 __ InvokeFunction(edi, actual, CALL_FUNCTION, &safepoint_generator); | 2163 __ InvokeFunction(edi, actual, CALL_FUNCTION, &safepoint_generator); |
| 2153 | 2164 |
| 2154 // Restore context. | 2165 // Restore context. |
| 2155 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2166 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2156 } | 2167 } |
| 2157 | 2168 |
| 2158 | 2169 |
| 2159 void LCodeGen::DoPushArgument(LPushArgument* instr) { | 2170 void LCodeGen::DoPushArgument(LPushArgument* instr) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2197 __ mov(eax, arity); | 2208 __ mov(eax, arity); |
| 2198 } | 2209 } |
| 2199 | 2210 |
| 2200 LPointerMap* pointers = instr->pointer_map(); | 2211 LPointerMap* pointers = instr->pointer_map(); |
| 2201 RecordPosition(pointers->position()); | 2212 RecordPosition(pointers->position()); |
| 2202 | 2213 |
| 2203 // Invoke function. | 2214 // Invoke function. |
| 2204 if (*function == *graph()->info()->closure()) { | 2215 if (*function == *graph()->info()->closure()) { |
| 2205 __ CallSelf(); | 2216 __ CallSelf(); |
| 2206 } else { | 2217 } else { |
| 2218 // This is an indirect call and will not be recorded in the reloc info. | |
| 2219 // Add a comment to the reloc info in case we need to patch this during | |
| 2220 // deoptimization. | |
| 2221 __ RecordComment(RelocInfo::kFillerCommentString, true); | |
| 2207 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset)); | 2222 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset)); |
| 2208 } | 2223 } |
| 2209 | 2224 |
| 2210 // Setup deoptimization. | 2225 // Setup deoptimization. |
| 2211 RegisterLazyDeoptimization(instr); | 2226 RegisterLazyDeoptimization(instr); |
| 2212 | 2227 |
| 2213 // Restore context. | 2228 // Restore context. |
| 2214 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2229 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2215 } | 2230 } |
| 2216 | 2231 |
| (...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3577 if (key->IsConstantOperand()) { | 3592 if (key->IsConstantOperand()) { |
| 3578 __ push(ToImmediate(key)); | 3593 __ push(ToImmediate(key)); |
| 3579 } else { | 3594 } else { |
| 3580 __ push(ToOperand(key)); | 3595 __ push(ToOperand(key)); |
| 3581 } | 3596 } |
| 3582 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); | 3597 ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment()); |
| 3583 LPointerMap* pointers = instr->pointer_map(); | 3598 LPointerMap* pointers = instr->pointer_map(); |
| 3584 LEnvironment* env = instr->deoptimization_environment(); | 3599 LEnvironment* env = instr->deoptimization_environment(); |
| 3585 RecordPosition(pointers->position()); | 3600 RecordPosition(pointers->position()); |
| 3586 RegisterEnvironmentForDeoptimization(env); | 3601 RegisterEnvironmentForDeoptimization(env); |
| 3602 // Create safepoint generator that will also ensure enough space in the | |
| 3603 // reloc info for patching in deoptimization (since this is invoking a | |
| 3604 // builtin) | |
| 3605 | |
| 3587 SafepointGenerator safepoint_generator(this, | 3606 SafepointGenerator safepoint_generator(this, |
| 3588 pointers, | 3607 pointers, |
| 3589 env->deoptimization_index()); | 3608 env->deoptimization_index(), |
| 3609 true); | |
| 3590 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator); | 3610 __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator); |
| 3591 } | 3611 } |
| 3592 | 3612 |
| 3593 | 3613 |
| 3594 void LCodeGen::DoStackCheck(LStackCheck* instr) { | 3614 void LCodeGen::DoStackCheck(LStackCheck* instr) { |
| 3595 // Perform stack overflow check. | 3615 // Perform stack overflow check. |
| 3596 NearLabel done; | 3616 NearLabel done; |
| 3597 ExternalReference stack_limit = ExternalReference::address_of_stack_limit(); | 3617 ExternalReference stack_limit = ExternalReference::address_of_stack_limit(); |
| 3598 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 3618 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
| 3599 __ j(above_equal, &done); | 3619 __ j(above_equal, &done); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 3619 ASSERT(osr_pc_offset_ == -1); | 3639 ASSERT(osr_pc_offset_ == -1); |
| 3620 osr_pc_offset_ = masm()->pc_offset(); | 3640 osr_pc_offset_ = masm()->pc_offset(); |
| 3621 } | 3641 } |
| 3622 | 3642 |
| 3623 | 3643 |
| 3624 #undef __ | 3644 #undef __ |
| 3625 | 3645 |
| 3626 } } // namespace v8::internal | 3646 } } // namespace v8::internal |
| 3627 | 3647 |
| 3628 #endif // V8_TARGET_ARCH_IA32 | 3648 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |