| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 case TOS_REG: return "TOS_REG"; | 116 case TOS_REG: return "TOS_REG"; |
| 117 } | 117 } |
| 118 UNREACHABLE(); | 118 UNREACHABLE(); |
| 119 return NULL; | 119 return NULL; |
| 120 } | 120 } |
| 121 | 121 |
| 122 Zone* zone() const { return zone_; } | 122 Zone* zone() const { return zone_; } |
| 123 | 123 |
| 124 static const int kMaxBackEdgeWeight = 127; | 124 static const int kMaxBackEdgeWeight = 127; |
| 125 | 125 |
| 126 // Platform-specific code size multiplier. |
| 126 #if V8_TARGET_ARCH_IA32 | 127 #if V8_TARGET_ARCH_IA32 |
| 127 static const int kBackEdgeDistanceUnit = 100; | 128 static const int kCodeSizeMultiplier = 100; |
| 128 #elif V8_TARGET_ARCH_X64 | 129 #elif V8_TARGET_ARCH_X64 |
| 129 static const int kBackEdgeDistanceUnit = 162; | 130 static const int kCodeSizeMultiplier = 162; |
| 130 #elif V8_TARGET_ARCH_ARM | 131 #elif V8_TARGET_ARCH_ARM |
| 131 static const int kBackEdgeDistanceUnit = 142; | 132 static const int kCodeSizeMultiplier = 142; |
| 132 #elif V8_TARGET_ARCH_MIPS | |
| 133 static const int kBackEdgeDistanceUnit = 142; | |
| 134 #elif V8_TARGET_ARCH_A64 | 133 #elif V8_TARGET_ARCH_A64 |
| 135 // TODO(all): Copied ARM value. Check this is sensible for A64. | 134 // TODO(all): Copied ARM value. Check this is sensible for A64. |
| 136 static const int kBackEdgeDistanceUnit = 142; | 135 static const int kCodeSizeMultiplier = 142; |
| 136 #elif V8_TARGET_ARCH_MIPS |
| 137 static const int kCodeSizeMultiplier = 142; |
| 137 #else | 138 #else |
| 138 #error Unsupported target architecture. | 139 #error Unsupported target architecture. |
| 139 #endif | 140 #endif |
| 140 | 141 |
| 141 static const int kBackEdgeEntrySize = 2 * kIntSize + kOneByteSize; | 142 static const int kBackEdgeEntrySize = 2 * kIntSize + kOneByteSize; |
| 142 | 143 |
| 143 private: | 144 private: |
| 144 class Breakable; | 145 class Breakable; |
| 145 class Iteration; | 146 class Iteration; |
| 146 | 147 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 407 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 407 void DeclareModules(Handle<FixedArray> descriptions); | 408 void DeclareModules(Handle<FixedArray> descriptions); |
| 408 void DeclareGlobals(Handle<FixedArray> pairs); | 409 void DeclareGlobals(Handle<FixedArray> pairs); |
| 409 int DeclareGlobalsFlags(); | 410 int DeclareGlobalsFlags(); |
| 410 | 411 |
| 411 // Generate code to allocate all (including nested) modules and contexts. | 412 // Generate code to allocate all (including nested) modules and contexts. |
| 412 // Because of recursive linking and the presence of module alias declarations, | 413 // Because of recursive linking and the presence of module alias declarations, |
| 413 // this has to be a separate pass _before_ populating or executing any module. | 414 // this has to be a separate pass _before_ populating or executing any module. |
| 414 void AllocateModules(ZoneList<Declaration*>* declarations); | 415 void AllocateModules(ZoneList<Declaration*>* declarations); |
| 415 | 416 |
| 416 // Generator code to return a fresh iterator result object. The "value" | 417 // Generate code to create an iterator result object. The "value" property is |
| 417 // property is set to a value popped from the stack, and "done" is set | 418 // set to a value popped from the stack, and "done" is set according to the |
| 418 // according to the argument. | 419 // argument. The result object is left in the result register. |
| 419 void EmitReturnIteratorResult(bool done); | 420 void EmitCreateIteratorResult(bool done); |
| 420 | 421 |
| 421 // Try to perform a comparison as a fast inlined literal compare if | 422 // Try to perform a comparison as a fast inlined literal compare if |
| 422 // the operands allow it. Returns true if the compare operations | 423 // the operands allow it. Returns true if the compare operations |
| 423 // has been matched and all code generated; false otherwise. | 424 // has been matched and all code generated; false otherwise. |
| 424 bool TryLiteralCompare(CompareOperation* compare); | 425 bool TryLiteralCompare(CompareOperation* compare); |
| 425 | 426 |
| 426 // Platform-specific code for comparing the type of a value with | 427 // Platform-specific code for comparing the type of a value with |
| 427 // a given literal string. | 428 // a given literal string. |
| 428 void EmitLiteralCompareTypeof(Expression* expr, | 429 void EmitLiteralCompareTypeof(Expression* expr, |
| 429 Expression* sub_expr, | 430 Expression* sub_expr, |
| 430 Handle<String> check); | 431 Handle<String> check); |
| 431 | 432 |
| 432 // Platform-specific code for equality comparison with a nil-like value. | 433 // Platform-specific code for equality comparison with a nil-like value. |
| 433 void EmitLiteralCompareNil(CompareOperation* expr, | 434 void EmitLiteralCompareNil(CompareOperation* expr, |
| 434 Expression* sub_expr, | 435 Expression* sub_expr, |
| 435 NilValue nil); | 436 NilValue nil); |
| 436 | 437 |
| 437 // Bailout support. | 438 // Bailout support. |
| 438 void PrepareForBailout(Expression* node, State state); | 439 void PrepareForBailout(Expression* node, State state); |
| 439 void PrepareForBailoutForId(BailoutId id, State state); | 440 void PrepareForBailoutForId(BailoutId id, State state); |
| 440 | 441 |
| 441 // Cache cell support. This associates AST ids with global property cells | 442 // Cache cell support. This associates AST ids with global property cells |
| 442 // that will be cleared during GC and collected by the type-feedback oracle. | 443 // that will be cleared during GC and collected by the type-feedback oracle. |
| 443 void RecordTypeFeedbackCell(TypeFeedbackId id, | 444 void RecordTypeFeedbackCell(TypeFeedbackId id, Handle<Cell> cell); |
| 444 Handle<JSGlobalPropertyCell> cell); | |
| 445 | 445 |
| 446 // Record a call's return site offset, used to rebuild the frame if the | 446 // Record a call's return site offset, used to rebuild the frame if the |
| 447 // called function was inlined at the site. | 447 // called function was inlined at the site. |
| 448 void RecordJSReturnSite(Call* call); | 448 void RecordJSReturnSite(Call* call); |
| 449 | 449 |
| 450 // Prepare for bailout before a test (or compare) and branch. If | 450 // Prepare for bailout before a test (or compare) and branch. If |
| 451 // should_normalize, then the following comparison will not handle the | 451 // should_normalize, then the following comparison will not handle the |
| 452 // canonical JS true value so we will insert a (dead) test against true at | 452 // canonical JS true value so we will insert a (dead) test against true at |
| 453 // the actual bailout target from the optimized code. If not | 453 // the actual bailout target from the optimized code. If not |
| 454 // should_normalize, the true and false labels are ignored. | 454 // should_normalize, the true and false labels are ignored. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 468 Label* back_edge_target); | 468 Label* back_edge_target); |
| 469 // Record the OSR AST id corresponding to a back edge in the code. | 469 // Record the OSR AST id corresponding to a back edge in the code. |
| 470 void RecordBackEdge(BailoutId osr_ast_id); | 470 void RecordBackEdge(BailoutId osr_ast_id); |
| 471 // Emit a table of back edge ids, pcs and loop depths into the code stream. | 471 // Emit a table of back edge ids, pcs and loop depths into the code stream. |
| 472 // Return the offset of the start of the table. | 472 // Return the offset of the start of the table. |
| 473 unsigned EmitBackEdgeTable(); | 473 unsigned EmitBackEdgeTable(); |
| 474 | 474 |
| 475 void EmitProfilingCounterDecrement(int delta); | 475 void EmitProfilingCounterDecrement(int delta); |
| 476 void EmitProfilingCounterReset(); | 476 void EmitProfilingCounterReset(); |
| 477 | 477 |
| 478 // Emit code to pop values from the stack associated with nested statements |
| 479 // like try/catch, try/finally, etc, running the finallies and unwinding the |
| 480 // handlers as needed. |
| 481 void EmitUnwindBeforeReturn(); |
| 482 |
| 478 // Platform-specific return sequence | 483 // Platform-specific return sequence |
| 479 void EmitReturnSequence(); | 484 void EmitReturnSequence(); |
| 480 | 485 |
| 481 // Platform-specific code sequences for calls | 486 // Platform-specific code sequences for calls |
| 482 void EmitCallWithStub(Call* expr, CallFunctionFlags flags); | 487 void EmitCallWithStub(Call* expr, CallFunctionFlags flags); |
| 483 void EmitCallWithIC(Call* expr, Handle<Object> name, RelocInfo::Mode mode); | 488 void EmitCallWithIC(Call* expr, Handle<Object> name, RelocInfo::Mode mode); |
| 484 void EmitKeyedCallWithIC(Call* expr, Expression* key); | 489 void EmitKeyedCallWithIC(Call* expr, Expression* key); |
| 485 | 490 |
| 486 // Platform-specific code for inline runtime calls. | 491 // Platform-specific code for inline runtime calls. |
| 487 InlineFunctionGenerator FindInlineFunctionGenerator(Runtime::FunctionId id); | 492 InlineFunctionGenerator FindInlineFunctionGenerator(Runtime::FunctionId id); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 }; | 649 }; |
| 645 | 650 |
| 646 struct BackEdgeEntry { | 651 struct BackEdgeEntry { |
| 647 BailoutId id; | 652 BailoutId id; |
| 648 unsigned pc; | 653 unsigned pc; |
| 649 uint8_t loop_depth; | 654 uint8_t loop_depth; |
| 650 }; | 655 }; |
| 651 | 656 |
| 652 struct TypeFeedbackCellEntry { | 657 struct TypeFeedbackCellEntry { |
| 653 TypeFeedbackId ast_id; | 658 TypeFeedbackId ast_id; |
| 654 Handle<JSGlobalPropertyCell> cell; | 659 Handle<Cell> cell; |
| 655 }; | 660 }; |
| 656 | 661 |
| 657 | 662 |
| 658 class ExpressionContext BASE_EMBEDDED { | 663 class ExpressionContext BASE_EMBEDDED { |
| 659 public: | 664 public: |
| 660 explicit ExpressionContext(FullCodeGenerator* codegen) | 665 explicit ExpressionContext(FullCodeGenerator* codegen) |
| 661 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) { | 666 : masm_(codegen->masm()), old_(codegen->context()), codegen_(codegen) { |
| 662 codegen->set_new_context(this); | 667 codegen->set_new_context(this); |
| 663 } | 668 } |
| 664 | 669 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 ZoneList<Handle<Object> >* globals_; | 845 ZoneList<Handle<Object> >* globals_; |
| 841 Handle<FixedArray> modules_; | 846 Handle<FixedArray> modules_; |
| 842 int module_index_; | 847 int module_index_; |
| 843 const ExpressionContext* context_; | 848 const ExpressionContext* context_; |
| 844 ZoneList<BailoutEntry> bailout_entries_; | 849 ZoneList<BailoutEntry> bailout_entries_; |
| 845 GrowableBitVector prepared_bailout_ids_; | 850 GrowableBitVector prepared_bailout_ids_; |
| 846 ZoneList<BackEdgeEntry> back_edges_; | 851 ZoneList<BackEdgeEntry> back_edges_; |
| 847 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; | 852 ZoneList<TypeFeedbackCellEntry> type_feedback_cells_; |
| 848 int ic_total_count_; | 853 int ic_total_count_; |
| 849 Handle<FixedArray> handler_table_; | 854 Handle<FixedArray> handler_table_; |
| 850 Handle<JSGlobalPropertyCell> profiling_counter_; | 855 Handle<Cell> profiling_counter_; |
| 851 bool generate_debug_code_; | 856 bool generate_debug_code_; |
| 852 Zone* zone_; | 857 Zone* zone_; |
| 853 | 858 |
| 854 friend class NestedStatement; | 859 friend class NestedStatement; |
| 855 | 860 |
| 856 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 861 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 857 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); | 862 DISALLOW_COPY_AND_ASSIGN(FullCodeGenerator); |
| 858 }; | 863 }; |
| 859 | 864 |
| 860 | 865 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 876 } | 881 } |
| 877 | 882 |
| 878 private: | 883 private: |
| 879 Zone* zone_; | 884 Zone* zone_; |
| 880 }; | 885 }; |
| 881 | 886 |
| 882 | 887 |
| 883 } } // namespace v8::internal | 888 } } // namespace v8::internal |
| 884 | 889 |
| 885 #endif // V8_FULL_CODEGEN_H_ | 890 #endif // V8_FULL_CODEGEN_H_ |
| OLD | NEW |