| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 20 matching lines...) Expand all Loading... |
| 31 #include "v8.h" | 31 #include "v8.h" |
| 32 | 32 |
| 33 #include "ast.h" | 33 #include "ast.h" |
| 34 #include "code-stubs.h" | 34 #include "code-stubs.h" |
| 35 #include "codegen.h" | 35 #include "codegen.h" |
| 36 #include "compiler.h" | 36 #include "compiler.h" |
| 37 | 37 |
| 38 namespace v8 { | 38 namespace v8 { |
| 39 namespace internal { | 39 namespace internal { |
| 40 | 40 |
| 41 // Forward declarations. |
| 42 class JumpPatchSite; |
| 43 |
| 41 // AST node visitor which can tell whether a given statement will be breakable | 44 // AST node visitor which can tell whether a given statement will be breakable |
| 42 // when the code is compiled by the full compiler in the debugger. This means | 45 // when the code is compiled by the full compiler in the debugger. This means |
| 43 // that there will be an IC (load/store/call) in the code generated for the | 46 // that there will be an IC (load/store/call) in the code generated for the |
| 44 // debugger to piggybag on. | 47 // debugger to piggybag on. |
| 45 class BreakableStatementChecker: public AstVisitor { | 48 class BreakableStatementChecker: public AstVisitor { |
| 46 public: | 49 public: |
| 47 BreakableStatementChecker() : is_breakable_(false) {} | 50 BreakableStatementChecker() : is_breakable_(false) {} |
| 48 | 51 |
| 49 void Check(Statement* stmt); | 52 void Check(Statement* stmt); |
| 50 void Check(Expression* stmt); | 53 void Check(Expression* stmt); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 kLeftConstant, | 280 kLeftConstant, |
| 278 kRightConstant | 281 kRightConstant |
| 279 }; | 282 }; |
| 280 | 283 |
| 281 // Type of a member function that generates inline code for a native function. | 284 // Type of a member function that generates inline code for a native function. |
| 282 typedef void (FullCodeGenerator::*InlineFunctionGenerator) | 285 typedef void (FullCodeGenerator::*InlineFunctionGenerator) |
| 283 (ZoneList<Expression*>*); | 286 (ZoneList<Expression*>*); |
| 284 | 287 |
| 285 static const InlineFunctionGenerator kInlineFunctionGenerators[]; | 288 static const InlineFunctionGenerator kInlineFunctionGenerators[]; |
| 286 | 289 |
| 290 // A platform-specific utility to overwrite the accumulator register |
| 291 // with a GC-safe value. |
| 292 void ClearAccumulator(); |
| 293 |
| 287 // Compute the frame pointer relative offset for a given local or | 294 // Compute the frame pointer relative offset for a given local or |
| 288 // parameter slot. | 295 // parameter slot. |
| 289 int SlotOffset(Slot* slot); | 296 int SlotOffset(Slot* slot); |
| 290 | 297 |
| 291 // Determine whether or not to inline the smi case for the given | 298 // Determine whether or not to inline the smi case for the given |
| 292 // operation. | 299 // operation. |
| 293 bool ShouldInlineSmiCase(Token::Value op); | 300 bool ShouldInlineSmiCase(Token::Value op); |
| 294 | 301 |
| 295 // Compute which (if any) of the operands is a compile-time constant. | 302 // Compute which (if any) of the operands is a compile-time constant. |
| 296 ConstantOperand GetConstantOperand(Token::Value op, | 303 ConstantOperand GetConstantOperand(Token::Value op, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 bool left_is_constant_smi, | 482 bool left_is_constant_smi, |
| 476 Smi* value); | 483 Smi* value); |
| 477 | 484 |
| 478 void EmitConstantSmiSub(Expression* expr, | 485 void EmitConstantSmiSub(Expression* expr, |
| 479 OverwriteMode mode, | 486 OverwriteMode mode, |
| 480 bool left_is_constant_smi, | 487 bool left_is_constant_smi, |
| 481 Smi* value); | 488 Smi* value); |
| 482 | 489 |
| 483 // Assign to the given expression as if via '='. The right-hand-side value | 490 // Assign to the given expression as if via '='. The right-hand-side value |
| 484 // is expected in the accumulator. | 491 // is expected in the accumulator. |
| 485 void EmitAssignment(Expression* expr); | 492 void EmitAssignment(Expression* expr, int bailout_ast_id); |
| 486 | 493 |
| 487 // Complete a variable assignment. The right-hand-side value is expected | 494 // Complete a variable assignment. The right-hand-side value is expected |
| 488 // in the accumulator. | 495 // in the accumulator. |
| 489 void EmitVariableAssignment(Variable* var, | 496 void EmitVariableAssignment(Variable* var, |
| 490 Token::Value op); | 497 Token::Value op); |
| 491 | 498 |
| 492 // Complete a named property assignment. The receiver is expected on top | 499 // Complete a named property assignment. The receiver is expected on top |
| 493 // of the stack and the right-hand-side value in the accumulator. | 500 // of the stack and the right-hand-side value in the accumulator. |
| 494 void EmitNamedPropertyAssignment(Assignment* expr); | 501 void EmitNamedPropertyAssignment(Assignment* expr); |
| 495 | 502 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 bool is_eval() { return info_->is_eval(); } | 535 bool is_eval() { return info_->is_eval(); } |
| 529 FunctionLiteral* function() { return info_->function(); } | 536 FunctionLiteral* function() { return info_->function(); } |
| 530 Scope* scope() { return info_->scope(); } | 537 Scope* scope() { return info_->scope(); } |
| 531 | 538 |
| 532 static Register result_register(); | 539 static Register result_register(); |
| 533 static Register context_register(); | 540 static Register context_register(); |
| 534 | 541 |
| 535 // Helper for calling an IC stub. | 542 // Helper for calling an IC stub. |
| 536 void EmitCallIC(Handle<Code> ic, RelocInfo::Mode mode); | 543 void EmitCallIC(Handle<Code> ic, RelocInfo::Mode mode); |
| 537 | 544 |
| 545 // Calling an IC stub with a patch site. Passing NULL for patch_site |
| 546 // indicates no inlined smi code and emits a nop after the IC call. |
| 547 void EmitCallIC(Handle<Code> ic, JumpPatchSite* patch_site); |
| 548 |
| 538 // Set fields in the stack frame. Offsets are the frame pointer relative | 549 // Set fields in the stack frame. Offsets are the frame pointer relative |
| 539 // offsets defined in, e.g., StandardFrameConstants. | 550 // offsets defined in, e.g., StandardFrameConstants. |
| 540 void StoreToFrameField(int frame_offset, Register value); | 551 void StoreToFrameField(int frame_offset, Register value); |
| 541 | 552 |
| 542 // Load a value from the current context. Indices are defined as an enum | 553 // Load a value from the current context. Indices are defined as an enum |
| 543 // in v8::internal::Context. | 554 // in v8::internal::Context. |
| 544 void LoadContextField(Register dst, int context_index); | 555 void LoadContextField(Register dst, int context_index); |
| 545 | 556 |
| 546 // AST node visit functions. | 557 // AST node visit functions. |
| 547 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 558 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 | 772 |
| 762 friend class NestedStatement; | 773 friend class NestedStatement; |
| 763 | 774 |
| 764 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 775 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
| 765 }; | 776 }; |
| 766 | 777 |
| 767 | 778 |
| 768 } } // namespace v8::internal | 779 } } // namespace v8::internal |
| 769 | 780 |
| 770 #endif // V8_FULL_CODEGEN_H_ | 781 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |