| 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 314 |
| 315 void DeleteFrame(); | 315 void DeleteFrame(); |
| 316 | 316 |
| 317 RegisterAllocator* allocator() const { return allocator_; } | 317 RegisterAllocator* allocator() const { return allocator_; } |
| 318 | 318 |
| 319 CodeGenState* state() { return state_; } | 319 CodeGenState* state() { return state_; } |
| 320 void set_state(CodeGenState* state) { state_ = state; } | 320 void set_state(CodeGenState* state) { state_ = state; } |
| 321 | 321 |
| 322 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } | 322 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } |
| 323 | 323 |
| 324 #ifdef DEBUG |
| 324 bool in_spilled_code() const { return in_spilled_code_; } | 325 bool in_spilled_code() const { return in_spilled_code_; } |
| 325 void set_in_spilled_code(bool flag) { in_spilled_code_ = flag; } | 326 void set_in_spilled_code(bool flag) { in_spilled_code_ = flag; } |
| 327 #endif |
| 326 | 328 |
| 327 private: | 329 private: |
| 328 // Construction/Destruction | 330 // Construction/Destruction |
| 329 CodeGenerator(int buffer_size, Handle<Script> script, bool is_eval); | 331 CodeGenerator(int buffer_size, Handle<Script> script, bool is_eval); |
| 330 virtual ~CodeGenerator() { delete masm_; } | 332 virtual ~CodeGenerator() { delete masm_; } |
| 331 | 333 |
| 332 // Accessors | 334 // Accessors |
| 333 Scope* scope() const { return scope_; } | 335 Scope* scope() const { return scope_; } |
| 334 | 336 |
| 335 // Clearing and generating deferred code. | 337 // Clearing and generating deferred code. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 353 | 355 |
| 354 #define DEF_VISIT(type) \ | 356 #define DEF_VISIT(type) \ |
| 355 void Visit##type(type* node); | 357 void Visit##type(type* node); |
| 356 NODE_LIST(DEF_VISIT) | 358 NODE_LIST(DEF_VISIT) |
| 357 #undef DEF_VISIT | 359 #undef DEF_VISIT |
| 358 | 360 |
| 359 // Visit a statement and then spill the virtual frame if control flow can | 361 // Visit a statement and then spill the virtual frame if control flow can |
| 360 // reach the end of the statement (ie, it does not exit via break, | 362 // reach the end of the statement (ie, it does not exit via break, |
| 361 // continue, return, or throw). This function is used temporarily while | 363 // continue, return, or throw). This function is used temporarily while |
| 362 // the code generator is being transformed. | 364 // the code generator is being transformed. |
| 363 void VisitAndSpill(Statement* statement); | 365 inline void VisitAndSpill(Statement* statement); |
| 364 | 366 |
| 365 // Visit a list of statements and then spill the virtual frame if control | 367 // Visit a list of statements and then spill the virtual frame if control |
| 366 // flow can reach the end of the list. | 368 // flow can reach the end of the list. |
| 367 void VisitStatementsAndSpill(ZoneList<Statement*>* statements); | 369 inline void VisitStatementsAndSpill(ZoneList<Statement*>* statements); |
| 368 | 370 |
| 369 // Main code generation function | 371 // Main code generation function |
| 370 void GenCode(FunctionLiteral* fun); | 372 void GenCode(FunctionLiteral* fun); |
| 371 | 373 |
| 372 // Generate the return sequence code. Should be called no more than | 374 // Generate the return sequence code. Should be called no more than |
| 373 // once per compiled function, immediately after binding the return | 375 // once per compiled function, immediately after binding the return |
| 374 // target (which can not be done more than once). | 376 // target (which can not be done more than once). |
| 375 void GenerateReturnSequence(Result* return_value); | 377 void GenerateReturnSequence(Result* return_value); |
| 376 | 378 |
| 377 // The following are used by class Reference. | 379 // The following are used by class Reference. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 397 TypeofState typeof_state, | 399 TypeofState typeof_state, |
| 398 ControlDestination* destination, | 400 ControlDestination* destination, |
| 399 bool force_control); | 401 bool force_control); |
| 400 void Load(Expression* x, TypeofState typeof_state = NOT_INSIDE_TYPEOF); | 402 void Load(Expression* x, TypeofState typeof_state = NOT_INSIDE_TYPEOF); |
| 401 void LoadGlobal(); | 403 void LoadGlobal(); |
| 402 void LoadGlobalReceiver(); | 404 void LoadGlobalReceiver(); |
| 403 | 405 |
| 404 // Generate code to push the value of an expression on top of the frame | 406 // Generate code to push the value of an expression on top of the frame |
| 405 // and then spill the frame fully to memory. This function is used | 407 // and then spill the frame fully to memory. This function is used |
| 406 // temporarily while the code generator is being transformed. | 408 // temporarily while the code generator is being transformed. |
| 407 void LoadAndSpill(Expression* expression, | 409 inline void LoadAndSpill(Expression* expression, |
| 408 TypeofState typeof_state = NOT_INSIDE_TYPEOF); | 410 TypeofState typeof_state = NOT_INSIDE_TYPEOF); |
| 409 | 411 |
| 410 // Read a value from a slot and leave it on top of the expression stack. | 412 // Read a value from a slot and leave it on top of the expression stack. |
| 411 void LoadFromSlot(Slot* slot, TypeofState typeof_state); | 413 void LoadFromSlot(Slot* slot, TypeofState typeof_state); |
| 412 Result LoadFromGlobalSlotCheckExtensions(Slot* slot, | 414 Result LoadFromGlobalSlotCheckExtensions(Slot* slot, |
| 413 TypeofState typeof_state, | 415 TypeofState typeof_state, |
| 414 JumpTarget* slow); | 416 JumpTarget* slow); |
| 415 | 417 |
| 416 // Store the value on top of the expression stack into a slot, leaving the | 418 // Store the value on top of the expression stack into a slot, leaving the |
| 417 // value in place. | 419 // value in place. |
| 418 void StoreToSlot(Slot* slot, InitState init_state); | 420 void StoreToSlot(Slot* slot, InitState init_state); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 | 601 |
| 600 // Jump targets. | 602 // Jump targets. |
| 601 // The target of the return from the function. | 603 // The target of the return from the function. |
| 602 BreakTarget function_return_; | 604 BreakTarget function_return_; |
| 603 | 605 |
| 604 // True if the function return is shadowed (ie, jumping to the target | 606 // True if the function return is shadowed (ie, jumping to the target |
| 605 // function_return_ does not jump to the true function return, but rather | 607 // function_return_ does not jump to the true function return, but rather |
| 606 // to some unlinking code). | 608 // to some unlinking code). |
| 607 bool function_return_is_shadowed_; | 609 bool function_return_is_shadowed_; |
| 608 | 610 |
| 611 #ifdef DEBUG |
| 609 // True when we are in code that expects the virtual frame to be fully | 612 // True when we are in code that expects the virtual frame to be fully |
| 610 // spilled. Some virtual frame function are disabled in DEBUG builds when | 613 // spilled. Some virtual frame function are disabled in DEBUG builds when |
| 611 // called from spilled code, because they do not leave the virtual frame | 614 // called from spilled code, because they do not leave the virtual frame |
| 612 // in a spilled state. | 615 // in a spilled state. |
| 613 bool in_spilled_code_; | 616 bool in_spilled_code_; |
| 617 #endif |
| 614 | 618 |
| 615 static InlineRuntimeLUT kInlineRuntimeLUT[]; | 619 static InlineRuntimeLUT kInlineRuntimeLUT[]; |
| 616 | 620 |
| 617 friend class VirtualFrame; | 621 friend class VirtualFrame; |
| 618 friend class JumpTarget; | 622 friend class JumpTarget; |
| 619 friend class Reference; | 623 friend class Reference; |
| 620 friend class Result; | 624 friend class Result; |
| 621 | 625 |
| 622 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); | 626 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
| 623 }; | 627 }; |
| 624 | 628 |
| 625 | 629 |
| 626 } } // namespace v8::internal | 630 } } // namespace v8::internal |
| 627 | 631 |
| 628 #endif // V8_X64_CODEGEN_X64_H_ | 632 #endif // V8_X64_CODEGEN_X64_H_ |
| OLD | NEW |