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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 current_block_(-1), | 50 current_block_(-1), |
51 current_instruction_(-1), | 51 current_instruction_(-1), |
52 instructions_(chunk->instructions()), | 52 instructions_(chunk->instructions()), |
53 deoptimizations_(4), | 53 deoptimizations_(4), |
54 deoptimization_literals_(8), | 54 deoptimization_literals_(8), |
55 inlined_function_count_(0), | 55 inlined_function_count_(0), |
56 scope_(info->scope()), | 56 scope_(info->scope()), |
57 status_(UNUSED), | 57 status_(UNUSED), |
58 deferred_(8), | 58 deferred_(8), |
59 osr_pc_offset_(-1), | 59 osr_pc_offset_(-1), |
60 resolver_(this) { | 60 resolver_(this), |
| 61 expected_safepoint_kind_(Safepoint::kSimple) { |
61 PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 62 PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
62 } | 63 } |
63 | 64 |
64 | 65 |
65 // Simple accessors. | 66 // Simple accessors. |
66 MacroAssembler* masm() const { return masm_; } | 67 MacroAssembler* masm() const { return masm_; } |
67 CompilationInfo* info() const { return info_; } | 68 CompilationInfo* info() const { return info_; } |
68 Isolate* isolate() const { return info_->isolate(); } | 69 Isolate* isolate() const { return info_->isolate(); } |
69 Factory* factory() const { return isolate()->factory(); } | 70 Factory* factory() const { return isolate()->factory(); } |
70 Heap* heap() const { return isolate()->heap(); } | 71 Heap* heap() const { return isolate()->heap(); } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 166 |
166 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } | 167 void AddDeferredCode(LDeferredCode* code) { deferred_.Add(code); } |
167 | 168 |
168 // Code generation passes. Returns true if code generation should | 169 // Code generation passes. Returns true if code generation should |
169 // continue. | 170 // continue. |
170 bool GeneratePrologue(); | 171 bool GeneratePrologue(); |
171 bool GenerateBody(); | 172 bool GenerateBody(); |
172 bool GenerateDeferredCode(); | 173 bool GenerateDeferredCode(); |
173 bool GenerateSafepointTable(); | 174 bool GenerateSafepointTable(); |
174 | 175 |
| 176 enum SafepointMode { |
| 177 RECORD_SIMPLE_SAFEPOINT, |
| 178 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS |
| 179 }; |
| 180 |
175 void CallCode(Handle<Code> code, | 181 void CallCode(Handle<Code> code, |
176 RelocInfo::Mode mode, | 182 RelocInfo::Mode mode, |
177 LInstruction* instr); | 183 LInstruction* instr); |
| 184 |
| 185 void CallCodeGeneric(Handle<Code> code, |
| 186 RelocInfo::Mode mode, |
| 187 LInstruction* instr, |
| 188 SafepointMode safepoint_mode); |
| 189 |
178 void CallRuntime(const Runtime::Function* function, | 190 void CallRuntime(const Runtime::Function* function, |
179 int num_arguments, | 191 int num_arguments, |
180 LInstruction* instr); | 192 LInstruction* instr); |
| 193 |
181 void CallRuntime(Runtime::FunctionId id, | 194 void CallRuntime(Runtime::FunctionId id, |
182 int num_arguments, | 195 int num_arguments, |
183 LInstruction* instr) { | 196 LInstruction* instr) { |
184 const Runtime::Function* function = Runtime::FunctionForId(id); | 197 const Runtime::Function* function = Runtime::FunctionForId(id); |
185 CallRuntime(function, num_arguments, instr); | 198 CallRuntime(function, num_arguments, instr); |
186 } | 199 } |
187 | 200 |
| 201 void CallRuntimeFromDeferred(Runtime::FunctionId id, |
| 202 int argc, |
| 203 LInstruction* instr); |
| 204 |
188 // Generate a direct call to a known function. Expects the function | 205 // Generate a direct call to a known function. Expects the function |
189 // to be in edi. | 206 // to be in edi. |
190 void CallKnownFunction(Handle<JSFunction> function, | 207 void CallKnownFunction(Handle<JSFunction> function, |
191 int arity, | 208 int arity, |
192 LInstruction* instr); | 209 LInstruction* instr); |
193 | 210 |
194 void LoadHeapObject(Register result, Handle<HeapObject> object); | 211 void LoadHeapObject(Register result, Handle<HeapObject> object); |
195 | 212 |
196 void RegisterLazyDeoptimization(LInstruction* instr); | 213 void RegisterLazyDeoptimization(LInstruction* instr, |
| 214 SafepointMode safepoint_mode); |
| 215 |
197 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); | 216 void RegisterEnvironmentForDeoptimization(LEnvironment* environment); |
198 void DeoptimizeIf(Condition cc, LEnvironment* environment); | 217 void DeoptimizeIf(Condition cc, LEnvironment* environment); |
199 | 218 |
200 void AddToTranslation(Translation* translation, | 219 void AddToTranslation(Translation* translation, |
201 LOperand* op, | 220 LOperand* op, |
202 bool is_tagged); | 221 bool is_tagged); |
203 void PopulateDeoptimizationData(Handle<Code> code); | 222 void PopulateDeoptimizationData(Handle<Code> code); |
204 int DefineDeoptimizationLiteral(Handle<Object> literal); | 223 int DefineDeoptimizationLiteral(Handle<Object> literal); |
205 | 224 |
206 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); | 225 void PopulateDeoptimizationLiteralsWithInlinedFunctions(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 ZoneList<LDeferredCode*> deferred_; | 304 ZoneList<LDeferredCode*> deferred_; |
286 int osr_pc_offset_; | 305 int osr_pc_offset_; |
287 | 306 |
288 // Builder that keeps track of safepoints in the code. The table | 307 // Builder that keeps track of safepoints in the code. The table |
289 // itself is emitted at the end of the generated code. | 308 // itself is emitted at the end of the generated code. |
290 SafepointTableBuilder safepoints_; | 309 SafepointTableBuilder safepoints_; |
291 | 310 |
292 // Compiler from a set of parallel moves to a sequential list of moves. | 311 // Compiler from a set of parallel moves to a sequential list of moves. |
293 LGapResolver resolver_; | 312 LGapResolver resolver_; |
294 | 313 |
| 314 Safepoint::Kind expected_safepoint_kind_; |
| 315 |
| 316 class PushSafepointRegistersScope BASE_EMBEDDED { |
| 317 public: |
| 318 PushSafepointRegistersScope(LCodeGen* codegen, |
| 319 Safepoint::Kind kind) |
| 320 : codegen_(codegen) { |
| 321 ASSERT(codegen_->expected_safepoint_kind_ == Safepoint::kSimple); |
| 322 codegen_->expected_safepoint_kind_ = kind; |
| 323 |
| 324 switch (codegen_->expected_safepoint_kind_) { |
| 325 case Safepoint::kWithRegisters: |
| 326 codegen_->masm_->PushSafepointRegisters(); |
| 327 break; |
| 328 case Safepoint::kWithRegistersAndDoubles: |
| 329 codegen_->masm_->PushSafepointRegistersAndDoubles(); |
| 330 break; |
| 331 default: |
| 332 UNREACHABLE(); |
| 333 } |
| 334 } |
| 335 |
| 336 ~PushSafepointRegistersScope() { |
| 337 Safepoint::Kind kind = codegen_->expected_safepoint_kind_; |
| 338 ASSERT((kind & Safepoint::kWithRegisters) != 0); |
| 339 switch (kind) { |
| 340 case Safepoint::kWithRegisters: |
| 341 codegen_->masm_->PopSafepointRegisters(); |
| 342 break; |
| 343 case Safepoint::kWithRegistersAndDoubles: |
| 344 codegen_->masm_->PopSafepointRegistersAndDoubles(); |
| 345 break; |
| 346 default: |
| 347 UNREACHABLE(); |
| 348 } |
| 349 codegen_->expected_safepoint_kind_ = Safepoint::kSimple; |
| 350 } |
| 351 |
| 352 private: |
| 353 LCodeGen* codegen_; |
| 354 }; |
| 355 |
295 friend class LDeferredCode; | 356 friend class LDeferredCode; |
296 friend class LEnvironment; | 357 friend class LEnvironment; |
297 friend class SafepointGenerator; | 358 friend class SafepointGenerator; |
298 DISALLOW_COPY_AND_ASSIGN(LCodeGen); | 359 DISALLOW_COPY_AND_ASSIGN(LCodeGen); |
299 }; | 360 }; |
300 | 361 |
301 | 362 |
302 class LDeferredCode: public ZoneObject { | 363 class LDeferredCode: public ZoneObject { |
303 public: | 364 public: |
304 explicit LDeferredCode(LCodeGen* codegen) | 365 explicit LDeferredCode(LCodeGen* codegen) |
(...skipping 15 matching lines...) Expand all Loading... |
320 private: | 381 private: |
321 LCodeGen* codegen_; | 382 LCodeGen* codegen_; |
322 Label entry_; | 383 Label entry_; |
323 Label exit_; | 384 Label exit_; |
324 Label* external_exit_; | 385 Label* external_exit_; |
325 }; | 386 }; |
326 | 387 |
327 } } // namespace v8::internal | 388 } } // namespace v8::internal |
328 | 389 |
329 #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ | 390 #endif // V8_ARM_LITHIUM_CODEGEN_ARM_H_ |
OLD | NEW |