| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 int end_position, | 155 int end_position, |
| 156 bool is_expression, | 156 bool is_expression, |
| 157 bool is_toplevel, | 157 bool is_toplevel, |
| 158 Handle<Script> script); | 158 Handle<Script> script); |
| 159 | 159 |
| 160 // Accessors | 160 // Accessors |
| 161 MacroAssembler* masm() { return masm_; } | 161 MacroAssembler* masm() { return masm_; } |
| 162 | 162 |
| 163 VirtualFrame* frame() const { return frame_; } | 163 VirtualFrame* frame() const { return frame_; } |
| 164 | 164 |
| 165 void set_frame(VirtualFrame* frame) { frame_ = frame; } | 165 bool has_valid_frame() const { return frame_ != NULL; } |
| 166 | 166 |
| 167 void delete_frame() { | 167 void SetFrame(VirtualFrame* frame); |
| 168 delete frame_; | 168 |
| 169 frame_ = NULL; | 169 void DeleteFrame(); |
| 170 } | |
| 171 | 170 |
| 172 CodeGenState* state() { return state_; } | 171 CodeGenState* state() { return state_; } |
| 173 void set_state(CodeGenState* state) { state_ = state; } | 172 void set_state(CodeGenState* state) { state_ = state; } |
| 174 | 173 |
| 175 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } | 174 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } |
| 176 | 175 |
| 177 private: | 176 private: |
| 178 // Construction/Destruction | 177 // Construction/Destruction |
| 179 CodeGenerator(int buffer_size, Handle<Script> script, bool is_eval); | 178 CodeGenerator(int buffer_size, Handle<Script> script, bool is_eval); |
| 180 virtual ~CodeGenerator() { delete masm_; } | 179 virtual ~CodeGenerator() { delete masm_; } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 // is optimal compared to the default code generated for a switch statement | 311 // is optimal compared to the default code generated for a switch statement |
| 313 // on that platform. | 312 // on that platform. |
| 314 int FastCaseSwitchMinCaseCount(); | 313 int FastCaseSwitchMinCaseCount(); |
| 315 | 314 |
| 316 // Allocate a jump table and create code to jump through it. | 315 // Allocate a jump table and create code to jump through it. |
| 317 // Should call GenerateFastCaseSwitchCases to generate the code for | 316 // Should call GenerateFastCaseSwitchCases to generate the code for |
| 318 // all the cases at the appropriate point. | 317 // all the cases at the appropriate point. |
| 319 void GenerateFastCaseSwitchJumpTable(SwitchStatement* node, | 318 void GenerateFastCaseSwitchJumpTable(SwitchStatement* node, |
| 320 int min_index, | 319 int min_index, |
| 321 int range, | 320 int range, |
| 322 JumpTarget* fail_label, | 321 Label* default_label, |
| 323 Vector<JumpTarget*> case_targets, | 322 Vector<Label*> case_targets, |
| 324 Vector<JumpTarget> case_labels); | 323 Vector<Label> case_labels); |
| 325 | 324 |
| 326 // Generate the code for cases for the fast case switch. | 325 // Generate the code for cases for the fast case switch. |
| 327 // Called by GenerateFastCaseSwitchJumpTable. | 326 // Called by GenerateFastCaseSwitchJumpTable. |
| 328 void GenerateFastCaseSwitchCases(SwitchStatement* node, | 327 void GenerateFastCaseSwitchCases(SwitchStatement* node, |
| 329 Vector<JumpTarget> case_labels, | 328 Vector<Label> case_labels, |
| 330 JumpTarget* table_start); | 329 VirtualFrame* start_frame); |
| 331 | 330 |
| 332 // Fast support for constant-Smi switches. | 331 // Fast support for constant-Smi switches. |
| 333 void GenerateFastCaseSwitchStatement(SwitchStatement* node, | 332 void GenerateFastCaseSwitchStatement(SwitchStatement* node, |
| 334 int min_index, | 333 int min_index, |
| 335 int range, | 334 int range, |
| 336 int default_index); | 335 int default_index); |
| 337 | 336 |
| 338 // Fast support for constant-Smi switches. Tests whether switch statement | 337 // Fast support for constant-Smi switches. Tests whether switch statement |
| 339 // permits optimization and calls GenerateFastCaseSwitch if it does. | 338 // permits optimization and calls GenerateFastCaseSwitch if it does. |
| 340 // Returns true if the fast-case switch was generated, and false if not. | 339 // Returns true if the fast-case switch was generated, and false if not. |
| 341 bool TryGenerateFastCaseSwitchStatement(SwitchStatement* node); | 340 bool TryGenerateFastCaseSwitchStatement(SwitchStatement* node); |
| 342 | 341 |
| 343 | 342 |
| 344 // Methods used to indicate which source code is generated for. Source | 343 // Methods used to indicate which source code is generated for. Source |
| 345 // positions are collected by the assembler and emitted with the relocation | 344 // positions are collected by the assembler and emitted with the relocation |
| 346 // information. | 345 // information. |
| 347 void CodeForStatement(Node* node); | 346 void CodeForFunctionPosition(FunctionLiteral* fun); |
| 347 void CodeForStatementPosition(Node* node); |
| 348 void CodeForSourcePosition(int pos); | 348 void CodeForSourcePosition(int pos); |
| 349 | 349 |
| 350 // Is the given jump target the actual (ie, non-shadowed) function return | 350 // Is the given jump target the actual (ie, non-shadowed) function return |
| 351 // target? | 351 // target? |
| 352 bool IsActualFunctionReturn(JumpTarget* target); | 352 bool IsActualFunctionReturn(JumpTarget* target); |
| 353 | 353 |
| 354 bool is_eval_; // Tells whether code is generated for eval. | 354 bool is_eval_; // Tells whether code is generated for eval. |
| 355 |
| 356 #ifdef DEBUG |
| 357 // True if the registers are valid for entry to a block. |
| 358 bool HasValidEntryRegisters(); |
| 359 #endif |
| 360 |
| 355 Handle<Script> script_; | 361 Handle<Script> script_; |
| 356 List<DeferredCode*> deferred_; | 362 List<DeferredCode*> deferred_; |
| 357 | 363 |
| 358 // Assembler | 364 // Assembler |
| 359 MacroAssembler* masm_; // to generate code | 365 MacroAssembler* masm_; // to generate code |
| 360 | 366 |
| 361 // Code generation state | 367 // Code generation state |
| 362 Scope* scope_; | 368 Scope* scope_; |
| 363 VirtualFrame* frame_; | 369 VirtualFrame* frame_; |
| 364 Condition cc_reg_; | 370 Condition cc_reg_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 377 friend class VirtualFrame; | 383 friend class VirtualFrame; |
| 378 friend class JumpTarget; | 384 friend class JumpTarget; |
| 379 friend class Reference; | 385 friend class Reference; |
| 380 | 386 |
| 381 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); | 387 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
| 382 }; | 388 }; |
| 383 | 389 |
| 384 } } // namespace v8::internal | 390 } } // namespace v8::internal |
| 385 | 391 |
| 386 #endif // V8_CODEGEN_ARM_H_ | 392 #endif // V8_CODEGEN_ARM_H_ |
| OLD | NEW |