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 24 matching lines...) Expand all Loading... | |
35 #include "safepoint-table.h" | 35 #include "safepoint-table.h" |
36 #include "scopes.h" | 36 #include "scopes.h" |
37 #include "x64/lithium-gap-resolver-x64.h" | 37 #include "x64/lithium-gap-resolver-x64.h" |
38 | 38 |
39 namespace v8 { | 39 namespace v8 { |
40 namespace internal { | 40 namespace internal { |
41 | 41 |
42 // Forward declarations. | 42 // Forward declarations. |
43 class LDeferredCode; | 43 class LDeferredCode; |
44 class SafepointGenerator; | 44 class SafepointGenerator; |
45 class JumpTableEntry; | |
45 | 46 |
46 class LCodeGen BASE_EMBEDDED { | 47 class LCodeGen BASE_EMBEDDED { |
47 public: | 48 public: |
48 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) | 49 LCodeGen(LChunk* chunk, MacroAssembler* assembler, CompilationInfo* info) |
49 : chunk_(chunk), | 50 : chunk_(chunk), |
50 masm_(assembler), | 51 masm_(assembler), |
51 info_(info), | 52 info_(info), |
52 current_block_(-1), | 53 current_block_(-1), |
53 current_instruction_(-1), | 54 current_instruction_(-1), |
54 instructions_(chunk->instructions()), | 55 instructions_(chunk->instructions()), |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 Label* is_not_object, | 234 Label* is_not_object, |
234 Label* is_object); | 235 Label* is_object); |
235 | 236 |
236 // Emits optimized code for %_IsConstructCall(). | 237 // Emits optimized code for %_IsConstructCall(). |
237 // Caller should branch on equal condition. | 238 // Caller should branch on equal condition. |
238 void EmitIsConstructCall(Register temp); | 239 void EmitIsConstructCall(Register temp); |
239 | 240 |
240 // Emits code for pushing a constant operand. | 241 // Emits code for pushing a constant operand. |
241 void EmitPushConstantOperand(LOperand* operand); | 242 void EmitPushConstantOperand(LOperand* operand); |
242 | 243 |
243 struct JumpTableEntry { | |
244 inline JumpTableEntry(Address address) | |
245 : label_(), | |
246 address_(address) { } | |
247 Label label_; | |
248 Address address_; | |
249 }; | |
250 | 244 |
251 LChunk* const chunk_; | 245 LChunk* const chunk_; |
252 MacroAssembler* const masm_; | 246 MacroAssembler* const masm_; |
253 CompilationInfo* const info_; | 247 CompilationInfo* const info_; |
254 | 248 |
255 int current_block_; | 249 int current_block_; |
256 int current_instruction_; | 250 int current_instruction_; |
257 const ZoneList<LInstruction*>* instructions_; | 251 const ZoneList<LInstruction*>* instructions_; |
258 ZoneList<LEnvironment*> deoptimizations_; | 252 ZoneList<LEnvironment*> deoptimizations_; |
259 ZoneList<JumpTableEntry*> jump_table_; | 253 ZoneList<JumpTableEntry*> jump_table_; |
260 ZoneList<Handle<Object> > deoptimization_literals_; | 254 ZoneList<Handle<Object> > deoptimization_literals_; |
261 int inlined_function_count_; | 255 int inlined_function_count_; |
262 Scope* const scope_; | 256 Scope* const scope_; |
263 Status status_; | 257 Status status_; |
264 TranslationBuffer translations_; | 258 TranslationBuffer translations_; |
265 ZoneList<LDeferredCode*> deferred_; | 259 ZoneList<LDeferredCode*> deferred_; |
266 int osr_pc_offset_; | 260 int osr_pc_offset_; |
267 | 261 |
268 // Builder that keeps track of safepoints in the code. The table | 262 // Builder that keeps track of safepoints in the code. The table |
269 // itself is emitted at the end of the generated code. | 263 // itself is emitted at the end of the generated code. |
270 SafepointTableBuilder safepoints_; | 264 SafepointTableBuilder safepoints_; |
271 | 265 |
272 // Compiler from a set of parallel moves to a sequential list of moves. | 266 // Compiler from a set of parallel moves to a sequential list of moves. |
273 LGapResolver resolver_; | 267 LGapResolver resolver_; |
274 | 268 |
275 friend class LDeferredCode; | 269 friend class LDeferredCode; |
276 friend class LEnvironment; | 270 friend class LEnvironment; |
277 friend class SafepointGenerator; | 271 friend class SafepointGenerator; |
272 friend class JumpTableEntry; | |
278 DISALLOW_COPY_AND_ASSIGN(LCodeGen); | 273 DISALLOW_COPY_AND_ASSIGN(LCodeGen); |
279 }; | 274 }; |
280 | 275 |
281 | 276 |
277 class JumpTableEntry : public ZoneObject { | |
Lasse Reichstein
2011/03/09 09:16:54
Why create an external class for a purely internal
| |
278 public: | |
279 explicit JumpTableEntry() : address_(NULL) { } | |
280 void SetAddress(Address address) { address_ = address; } | |
281 byte* address() { return address_; } | |
282 Label* label() { return &label_; } | |
283 | |
284 private: | |
285 Label label_; | |
286 byte* address_; | |
287 }; | |
288 | |
289 | |
282 class LDeferredCode: public ZoneObject { | 290 class LDeferredCode: public ZoneObject { |
283 public: | 291 public: |
284 explicit LDeferredCode(LCodeGen* codegen) | 292 explicit LDeferredCode(LCodeGen* codegen) |
285 : codegen_(codegen), external_exit_(NULL) { | 293 : codegen_(codegen), external_exit_(NULL) { |
286 codegen->AddDeferredCode(this); | 294 codegen->AddDeferredCode(this); |
287 } | 295 } |
288 | 296 |
289 virtual ~LDeferredCode() { } | 297 virtual ~LDeferredCode() { } |
290 virtual void Generate() = 0; | 298 virtual void Generate() = 0; |
291 | 299 |
292 void SetExit(Label *exit) { external_exit_ = exit; } | 300 void SetExit(Label *exit) { external_exit_ = exit; } |
293 Label* entry() { return &entry_; } | 301 Label* entry() { return &entry_; } |
294 Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; } | 302 Label* exit() { return external_exit_ != NULL ? external_exit_ : &exit_; } |
295 | 303 |
296 protected: | 304 protected: |
297 LCodeGen* codegen() const { return codegen_; } | 305 LCodeGen* codegen() const { return codegen_; } |
298 MacroAssembler* masm() const { return codegen_->masm(); } | 306 MacroAssembler* masm() const { return codegen_->masm(); } |
299 | 307 |
300 private: | 308 private: |
301 LCodeGen* codegen_; | 309 LCodeGen* codegen_; |
302 Label entry_; | 310 Label entry_; |
303 Label exit_; | 311 Label exit_; |
304 Label* external_exit_; | 312 Label* external_exit_; |
305 }; | 313 }; |
306 | 314 |
307 } } // namespace v8::internal | 315 } } // namespace v8::internal |
308 | 316 |
309 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ | 317 #endif // V8_X64_LITHIUM_CODEGEN_X64_H_ |
OLD | NEW |