| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // ----------------------------------------------------------------------------- | 61 // ----------------------------------------------------------------------------- |
| 62 // Full code generator. | 62 // Full code generator. |
| 63 | 63 |
| 64 class FullCodeGenerator: public AstVisitor { | 64 class FullCodeGenerator: public AstVisitor { |
| 65 public: | 65 public: |
| 66 enum Mode { | 66 enum Mode { |
| 67 PRIMARY, | 67 PRIMARY, |
| 68 SECONDARY | 68 SECONDARY |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 FullCodeGenerator(MacroAssembler* masm, Handle<Script> script, bool is_eval) | 71 FullCodeGenerator(MacroAssembler* masm) |
| 72 : masm_(masm), | 72 : masm_(masm), |
| 73 script_(script), | 73 info_(NULL), |
| 74 is_eval_(is_eval), | |
| 75 function_(NULL), | |
| 76 nesting_stack_(NULL), | 74 nesting_stack_(NULL), |
| 77 loop_depth_(0), | 75 loop_depth_(0), |
| 78 location_(kStack), | 76 location_(kStack), |
| 79 true_label_(NULL), | 77 true_label_(NULL), |
| 80 false_label_(NULL) { | 78 false_label_(NULL) { |
| 81 } | 79 } |
| 82 | 80 |
| 83 static Handle<Code> MakeCode(FunctionLiteral* fun, | 81 static Handle<Code> MakeCode(CompilationInfo* info); |
| 84 Handle<Script> script, | |
| 85 bool is_eval); | |
| 86 | 82 |
| 87 void Generate(FunctionLiteral* fun, Mode mode); | 83 void Generate(CompilationInfo* info, Mode mode); |
| 88 | 84 |
| 89 private: | 85 private: |
| 90 class Breakable; | 86 class Breakable; |
| 91 class Iteration; | 87 class Iteration; |
| 92 class TryCatch; | 88 class TryCatch; |
| 93 class TryFinally; | 89 class TryFinally; |
| 94 class Finally; | 90 class Finally; |
| 95 class ForIn; | 91 class ForIn; |
| 96 | 92 |
| 97 class NestedStatement BASE_EMBEDDED { | 93 class NestedStatement BASE_EMBEDDED { |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 397 |
| 402 // Loop nesting counter. | 398 // Loop nesting counter. |
| 403 int loop_depth() { return loop_depth_; } | 399 int loop_depth() { return loop_depth_; } |
| 404 void increment_loop_depth() { loop_depth_++; } | 400 void increment_loop_depth() { loop_depth_++; } |
| 405 void decrement_loop_depth() { | 401 void decrement_loop_depth() { |
| 406 ASSERT(loop_depth_ > 0); | 402 ASSERT(loop_depth_ > 0); |
| 407 loop_depth_--; | 403 loop_depth_--; |
| 408 } | 404 } |
| 409 | 405 |
| 410 MacroAssembler* masm() { return masm_; } | 406 MacroAssembler* masm() { return masm_; } |
| 407 |
| 408 Handle<Script> script() { return info_->script(); } |
| 409 bool is_eval() { return info_->is_eval(); } |
| 410 FunctionLiteral* function() { return info_->function(); } |
| 411 Scope* scope() { return info_->scope(); } |
| 412 |
| 411 static Register result_register(); | 413 static Register result_register(); |
| 412 static Register context_register(); | 414 static Register context_register(); |
| 413 | 415 |
| 414 // Set fields in the stack frame. Offsets are the frame pointer relative | 416 // Set fields in the stack frame. Offsets are the frame pointer relative |
| 415 // offsets defined in, e.g., StandardFrameConstants. | 417 // offsets defined in, e.g., StandardFrameConstants. |
| 416 void StoreToFrameField(int frame_offset, Register value); | 418 void StoreToFrameField(int frame_offset, Register value); |
| 417 | 419 |
| 418 // Load a value from the current context. Indices are defined as an enum | 420 // Load a value from the current context. Indices are defined as an enum |
| 419 // in v8::internal::Context. | 421 // in v8::internal::Context. |
| 420 void LoadContextField(Register dst, int context_index); | 422 void LoadContextField(Register dst, int context_index); |
| 421 | 423 |
| 422 // AST node visit functions. | 424 // AST node visit functions. |
| 423 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 425 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| 424 AST_NODE_LIST(DECLARE_VISIT) | 426 AST_NODE_LIST(DECLARE_VISIT) |
| 425 #undef DECLARE_VISIT | 427 #undef DECLARE_VISIT |
| 426 // Handles the shortcutted logical binary operations in VisitBinaryOperation. | 428 // Handles the shortcutted logical binary operations in VisitBinaryOperation. |
| 427 void EmitLogicalOperation(BinaryOperation* expr); | 429 void EmitLogicalOperation(BinaryOperation* expr); |
| 428 | 430 |
| 429 MacroAssembler* masm_; | 431 MacroAssembler* masm_; |
| 430 Handle<Script> script_; | 432 CompilationInfo* info_; |
| 431 bool is_eval_; | |
| 432 | |
| 433 FunctionLiteral* function_; | |
| 434 | 433 |
| 435 Label return_label_; | 434 Label return_label_; |
| 436 NestedStatement* nesting_stack_; | 435 NestedStatement* nesting_stack_; |
| 437 int loop_depth_; | 436 int loop_depth_; |
| 438 | 437 |
| 439 Expression::Context context_; | 438 Expression::Context context_; |
| 440 Location location_; | 439 Location location_; |
| 441 Label* true_label_; | 440 Label* true_label_; |
| 442 Label* false_label_; | 441 Label* false_label_; |
| 443 | 442 |
| 444 friend class NestedStatement; | 443 friend class NestedStatement; |
| 445 | 444 |
| 446 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 445 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
| 447 }; | 446 }; |
| 448 | 447 |
| 449 | 448 |
| 450 } } // namespace v8::internal | 449 } } // namespace v8::internal |
| 451 | 450 |
| 452 #endif // V8_FULL_CODEGEN_H_ | 451 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |