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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 current_instruction_(-1), | 53 current_instruction_(-1), |
54 instructions_(chunk->instructions()), | 54 instructions_(chunk->instructions()), |
55 deoptimizations_(4), | 55 deoptimizations_(4), |
56 jump_table_(4), | 56 jump_table_(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 resolver_(this) { | 63 resolver_(this), |
| 64 expected_safepoint_kind_(Safepoint::kSimple) { |
64 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 65 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
65 } | 66 } |
66 | 67 |
67 // Simple accessors. | 68 // Simple accessors. |
68 MacroAssembler* masm() const { return masm_; } | 69 MacroAssembler* masm() const { return masm_; } |
69 CompilationInfo* info() const { return info_; } | 70 CompilationInfo* info() const { return info_; } |
70 Isolate* isolate() const { return info_->isolate(); } | 71 Isolate* isolate() const { return info_->isolate(); } |
71 Factory* factory() const { return isolate()->factory(); } | 72 Factory* factory() const { return isolate()->factory(); } |
72 Heap* heap() const { return isolate()->heap(); } | 73 Heap* heap() const { return isolate()->heap(); } |
73 | 74 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } | 150 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } |
150 | 151 |
151 // Code generation passes. Returns true if code generation should | 152 // Code generation passes. Returns true if code generation should |
152 // continue. | 153 // continue. |
153 bool GeneratePrologue(); | 154 bool GeneratePrologue(); |
154 bool GenerateBody(); | 155 bool GenerateBody(); |
155 bool GenerateDeferredCode(); | 156 bool GenerateDeferredCode(); |
156 bool GenerateJumpTable(); | 157 bool GenerateJumpTable(); |
157 bool GenerateSafepointTable(); | 158 bool GenerateSafepointTable(); |
158 | 159 |
| 160 enum SafepointMode { |
| 161 RECORD_SIMPLE_SAFEPOINT, |
| 162 RECORD_SAFEPOINT_WITH_REGISTERS |
| 163 }; |
| 164 |
| 165 void CallCodeGeneric(Handle<Code> code, |
| 166 RelocInfo::Mode mode, |
| 167 LInstruction* instr, |
| 168 SafepointMode safepoint_mode, |
| 169 int argc); |
| 170 |
| 171 |
159 void CallCode(Handle<Code> code, | 172 void CallCode(Handle<Code> code, |
160 RelocInfo::Mode mode, | 173 RelocInfo::Mode mode, |
161 LInstruction* instr); | 174 LInstruction* instr); |
| 175 |
162 void CallRuntime(const Runtime::Function* function, | 176 void CallRuntime(const Runtime::Function* function, |
163 int num_arguments, | 177 int num_arguments, |
164 LInstruction* instr); | 178 LInstruction* instr); |
| 179 |
165 void CallRuntime(Runtime::FunctionId id, | 180 void CallRuntime(Runtime::FunctionId id, |
166 int num_arguments, | 181 int num_arguments, |
167 LInstruction* instr) { | 182 LInstruction* instr) { |
168 const Runtime::Function* function = Runtime::FunctionForId(id); | 183 const Runtime::Function* function = Runtime::FunctionForId(id); |
169 CallRuntime(function, num_arguments, instr); | 184 CallRuntime(function, num_arguments, instr); |
170 } | 185 } |
171 | 186 |
| 187 void CallRuntimeFromDeferred(Runtime::FunctionId id, |
| 188 int argc, |
| 189 LInstruction* instr); |
| 190 |
| 191 |
172 // Generate a direct call to a known function. Expects the function | 192 // Generate a direct call to a known function. Expects the function |
173 // to be in edi. | 193 // to be in edi. |
174 void CallKnownFunction(Handle<JSFunction> function, | 194 void CallKnownFunction(Handle<JSFunction> function, |
175 int arity, | 195 int arity, |
176 LInstruction* instr); | 196 LInstruction* instr); |
177 | 197 |
178 void LoadHeapObject(Register result, Handle<HeapObject> object); | 198 void LoadHeapObject(Register result, Handle<HeapObject> object); |
179 | 199 |
180 void RegisterLazyDeoptimization(LInstruction* instr); | 200 void RegisterLazyDeoptimization(LInstruction* instr, |
| 201 SafepointMode safepoint_mode, |
| 202 int argc); |
181 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); | 203 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); |
182 void DeoptimizeIf(Condition cc, LEnvironment* environment); | 204 void DeoptimizeIf(Condition cc, LEnvironment* environment); |
183 | 205 |
184 void AddToTranslation(Translation* translation, | 206 void AddToTranslation(Translation* translation, |
185 LOperand* op, | 207 LOperand* op, |
186 bool is_tagged); | 208 bool is_tagged); |
187 void PopulateDeoptimizationData(Handle<Code> code); | 209 void PopulateDeoptimizationData(Handle<Code> code); |
188 int DefineDeoptimizationLiteral(Handle<Object> literal); | 210 int DefineDeoptimizationLiteral(Handle<Object> literal); |
189 | 211 |
190 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 212 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 ZoneList<LDeferredCode*> deferred_; | 296 ZoneList<LDeferredCode*> deferred_; |
275 int osr_pc_offset_; | 297 int osr_pc_offset_; |
276 | 298 |
277 // Builder that keeps track of safepoints in the code. The table | 299 // Builder that keeps track of safepoints in the code. The table |
278 // itself is emitted at the end of the generated code. | 300 // itself is emitted at the end of the generated code. |
279 SafepointTableBuilder safepoints_; | 301 SafepointTableBuilder safepoints_; |
280 | 302 |
281 // Compiler from a set of parallel moves to a sequential list of moves. | 303 // Compiler from a set of parallel moves to a sequential list of moves. |
282 LGapResolver resolver_; | 304 LGapResolver resolver_; |
283 | 305 |
| 306 Safepoint::Kind expected_safepoint_kind_; |
| 307 |
| 308 class PushSafepointRegistersScope BASE_EMBEDDED { |
| 309 public: |
| 310 explicit PushSafepointRegistersScope(LCodeGen* codegen) |
| 311 : codegen_(codegen) { |
| 312 ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kSimple); |
| 313 codegen_->masm_->PushSafepointRegisters(); |
| 314 codegen_->expected_safepoint_kind_ = Safepoint::kWithRegisters; |
| 315 } |
| 316 |
| 317 ~PushSafepointRegistersScope() { |
| 318 ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kWithRegisters); |
| 319 codegen_->masm_->PopSafepointRegisters(); |
| 320 codegen_->expected_safepoint_kind_ = Safepoint::kSimple; |
| 321 } |
| 322 |
| 323 private: |
| 324 LCodeGen* codegen_; |
| 325 }; |
| 326 |
284 friend class LDeferredCode; | 327 friend class LDeferredCode; |
285 friend class LEnvironment; | 328 friend class LEnvironment; |
286 friend class SafepointGenerator; | 329 friend class SafepointGenerator; |
287 DISALLOW_COPY_AND_ASSIGN(LCodeGen); | 330 DISALLOW_COPY_AND_ASSIGN(LCodeGen); |
288 }; | 331 }; |
289 | 332 |
290 | 333 |
291 class LDeferredCode: public ZoneObject { | 334 class LDeferredCode: public ZoneObject { |
292 public: | 335 public: |
293 explicit LDeferredCode(LCodeGen* codegen) | 336 explicit LDeferredCode(LCodeGen* codegen) |
(...skipping 15 matching lines...) Expand all Loading... |
309 private: | 352 private: |
310 LCodeGen* codegen_; | 353 LCodeGen* codegen_; |
311 Label entry_; | 354 Label entry_; |
312 Label exit_; | 355 Label exit_; |
313 Label* external_exit_; | 356 Label* external_exit_; |
314 }; | 357 }; |
315 | 358 |
316 } } // namespace v8::internal | 359 } } // namespace v8::internal |
317 | 360 |
318 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ | 361 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ |
OLD | NEW |