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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 current_instruction_(-1), | 54 current_instruction_(-1), |
55 instructions_(chunk->instructions()), | 55 instructions_(chunk->instructions()), |
56 deoptimizations_(4), | 56 deoptimizations_(4), |
57 deoptimization_literals_(8), | 57 deoptimization_literals_(8), |
58 inlined_function_count_(0), | 58 inlined_function_count_(0), |
59 scope_(info->scope()), | 59 scope_(info->scope()), |
60 status_(UNUSED), | 60 status_(UNUSED), |
61 deferred_(8), | 61 deferred_(8), |
62 osr_pc_offset_(-1), | 62 osr_pc_offset_(-1), |
63 deoptimization_reloc_size(), | 63 deoptimization_reloc_size(), |
64 resolver_(this) { | 64 resolver_(this), |
| 65 expected_safepoint_kind_(Safepoint::kSimple) { |
65 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 66 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
66 } | 67 } |
67 | 68 |
68 // Simple accessors. | 69 // Simple accessors. |
69 MacroAssembler* masm() const { return masm_; } | 70 MacroAssembler* masm() const { return masm_; } |
70 CompilationInfo* info() const { return info_; } | 71 CompilationInfo* info() const { return info_; } |
71 Isolate* isolate() const { return info_->isolate(); } | 72 Isolate* isolate() const { return info_->isolate(); } |
72 Factory* factory() const { return isolate()->factory(); } | 73 Factory* factory() const { return isolate()->factory(); } |
73 Heap* heap() const { return isolate()->heap(); } | 74 Heap* heap() const { return isolate()->heap(); } |
74 | 75 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // Code generation passes. Returns true if code generation should | 158 // Code generation passes. Returns true if code generation should |
158 // continue. | 159 // continue. |
159 bool GeneratePrologue(); | 160 bool GeneratePrologue(); |
160 bool GenerateBody(); | 161 bool GenerateBody(); |
161 bool GenerateDeferredCode(); | 162 bool GenerateDeferredCode(); |
162 // Pad the reloc info to ensure that we have enough space to patch during | 163 // Pad the reloc info to ensure that we have enough space to patch during |
163 // deoptimization. | 164 // deoptimization. |
164 bool GenerateRelocPadding(); | 165 bool GenerateRelocPadding(); |
165 bool GenerateSafepointTable(); | 166 bool GenerateSafepointTable(); |
166 | 167 |
167 void CallCode(Handle<Code> code, RelocInfo::Mode mode, LInstruction* instr, | 168 enum ContextMode { |
168 bool adjusted = true); | 169 RESTORE_CONTEXT, |
169 void CallRuntime(const Runtime::Function* fun, int argc, LInstruction* instr, | 170 CONTEXT_ADJUSTED |
170 bool adjusted = true); | 171 }; |
171 void CallRuntime(Runtime::FunctionId id, int argc, LInstruction* instr, | 172 |
172 bool adjusted = true) { | 173 enum SafepointMode { |
| 174 RECORD_SIMPLE_SAFEPOINT, |
| 175 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS |
| 176 }; |
| 177 |
| 178 void CallCode(Handle<Code> code, |
| 179 RelocInfo::Mode mode, |
| 180 LInstruction* instr, |
| 181 ContextMode context_mode); |
| 182 |
| 183 void CallCodeGeneric(Handle<Code> code, |
| 184 RelocInfo::Mode mode, |
| 185 LInstruction* instr, |
| 186 ContextMode context_mode, |
| 187 SafepointMode safepoint_mode); |
| 188 |
| 189 void CallRuntime(const Runtime::Function* fun, |
| 190 int argc, |
| 191 LInstruction* instr, |
| 192 ContextMode context_mode); |
| 193 |
| 194 void CallRuntime(Runtime::FunctionId id, |
| 195 int argc, |
| 196 LInstruction* instr, |
| 197 ContextMode context_mode) { |
173 const Runtime::Function* function = Runtime::FunctionForId(id); | 198 const Runtime::Function* function = Runtime::FunctionForId(id); |
174 CallRuntime(function, argc, instr, adjusted); | 199 CallRuntime(function, argc, instr, context_mode); |
175 } | 200 } |
176 | 201 |
| 202 void CallRuntimeFromDeferred(Runtime::FunctionId id, |
| 203 int argc, |
| 204 LInstruction* instr); |
| 205 |
177 // Generate a direct call to a known function. Expects the function | 206 // Generate a direct call to a known function. Expects the function |
178 // to be in edi. | 207 // to be in edi. |
179 void CallKnownFunction(Handle<JSFunction> function, | 208 void CallKnownFunction(Handle<JSFunction> function, |
180 int arity, | 209 int arity, |
181 LInstruction* instr); | 210 LInstruction* instr); |
182 | 211 |
183 void LoadHeapObject(Register result, Handle<HeapObject> object); | 212 void LoadHeapObject(Register result, Handle<HeapObject> object); |
184 | 213 |
185 void RegisterLazyDeoptimization(LInstruction* instr); | 214 void RegisterLazyDeoptimization(LInstruction* instr, |
| 215 SafepointMode safepoint_mode); |
| 216 |
186 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); | 217 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); |
187 void DeoptimizeIf(Condition cc, LEnvironment* environment); | 218 void DeoptimizeIf(Condition cc, LEnvironment* environment); |
188 | 219 |
189 void AddToTranslation(Translation* translation, | 220 void AddToTranslation(Translation* translation, |
190 LOperand* op, | 221 LOperand* op, |
191 bool is_tagged); | 222 bool is_tagged); |
192 void PopulateDeoptimizationData(Handle<Code> code); | 223 void PopulateDeoptimizationData(Handle<Code> code); |
193 int DefineDeoptimizationLiteral(Handle<Object> literal); | 224 int DefineDeoptimizationLiteral(Handle<Object> literal); |
194 | 225 |
195 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 226 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 305 |
275 DeoptimizationRelocSize deoptimization_reloc_size; | 306 DeoptimizationRelocSize deoptimization_reloc_size; |
276 | 307 |
277 // Builder that keeps track of safepoints in the code. The table | 308 // Builder that keeps track of safepoints in the code. The table |
278 // itself is emitted at the end of the generated code. | 309 // itself is emitted at the end of the generated code. |
279 SafepointTableBuilder safepoints_; | 310 SafepointTableBuilder safepoints_; |
280 | 311 |
281 // Compiler from a set of parallel moves to a sequential list of moves. | 312 // Compiler from a set of parallel moves to a sequential list of moves. |
282 LGapResolver resolver_; | 313 LGapResolver resolver_; |
283 | 314 |
| 315 Safepoint::Kind expected_safepoint_kind_; |
| 316 |
| 317 class PushSafepointRegistersScope BASE_EMBEDDED { |
| 318 public: |
| 319 explicit PushSafepointRegistersScope(LCodeGen* codegen) |
| 320 : codegen_(codegen) { |
| 321 ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kSimple); |
| 322 codegen_->masm_->PushSafepointRegisters(); |
| 323 codegen_->expected_safepoint_kind_ = Safepoint::kWithRegisters; |
| 324 } |
| 325 |
| 326 ~PushSafepointRegistersScope() { |
| 327 ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kWithRegisters); |
| 328 codegen_->masm_->PopSafepointRegisters(); |
| 329 codegen_->expected_safepoint_kind_ = Safepoint::kSimple; |
| 330 } |
| 331 |
| 332 private: |
| 333 LCodeGen* codegen_; |
| 334 }; |
| 335 |
284 friend class LDeferredCode; | 336 friend class LDeferredCode; |
285 friend class LEnvironment; | 337 friend class LEnvironment; |
286 friend class SafepointGenerator; | 338 friend class SafepointGenerator; |
287 DISALLOW_COPY_AND_ASSIGN(LCodeGen); | 339 DISALLOW_COPY_AND_ASSIGN(LCodeGen); |
288 }; | 340 }; |
289 | 341 |
290 | 342 |
291 class LDeferredCode: public ZoneObject { | 343 class LDeferredCode: public ZoneObject { |
292 public: | 344 public: |
293 explicit LDeferredCode(LCodeGen* codegen) | 345 explicit LDeferredCode(LCodeGen* codegen) |
(...skipping 15 matching lines...) Expand all Loading... |
309 private: | 361 private: |
310 LCodeGen* codegen_; | 362 LCodeGen* codegen_; |
311 Label entry_; | 363 Label entry_; |
312 Label exit_; | 364 Label exit_; |
313 Label* external_exit_; | 365 Label* external_exit_; |
314 }; | 366 }; |
315 | 367 |
316 } } // namespace v8::internal | 368 } } // namespace v8::internal |
317 | 369 |
318 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ | 370 #endif // V8_IA32_LITHIUM_CODEGEN_IA32_H_ |
OLD | NEW |