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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 RegisterAllocator* allocator() const { return allocator_; } | 338 RegisterAllocator* allocator() const { return allocator_; } |
339 | 339 |
340 CodeGenState* state() { return state_; } | 340 CodeGenState* state() { return state_; } |
341 void set_state(CodeGenState* state) { state_ = state; } | 341 void set_state(CodeGenState* state) { state_ = state; } |
342 | 342 |
343 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } | 343 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } |
344 | 344 |
345 bool in_spilled_code() const { return in_spilled_code_; } | 345 bool in_spilled_code() const { return in_spilled_code_; } |
346 void set_in_spilled_code(bool flag) { in_spilled_code_ = flag; } | 346 void set_in_spilled_code(bool flag) { in_spilled_code_ = flag; } |
347 | 347 |
348 // If the name is an inline runtime function call return the number of | |
349 // expected arguments. Otherwise return -1. | |
350 static int InlineRuntimeCallArgumentsCount(Handle<String> name); | |
351 | |
352 // Return a position of the element at |index_as_smi| + |additional_offset| | 348 // Return a position of the element at |index_as_smi| + |additional_offset| |
353 // in FixedArray pointer to which is held in |array|. |index_as_smi| is Smi. | 349 // in FixedArray pointer to which is held in |array|. |index_as_smi| is Smi. |
354 static Operand FixedArrayElementOperand(Register array, | 350 static Operand FixedArrayElementOperand(Register array, |
355 Register index_as_smi, | 351 Register index_as_smi, |
356 int additional_offset = 0) { | 352 int additional_offset = 0) { |
357 int offset = FixedArray::kHeaderSize + additional_offset * kPointerSize; | 353 int offset = FixedArray::kHeaderSize + additional_offset * kPointerSize; |
358 return FieldOperand(array, index_as_smi, times_half_pointer_size, offset); | 354 return FieldOperand(array, index_as_smi, times_half_pointer_size, offset); |
359 } | 355 } |
360 | 356 |
361 static Operand ContextOperand(Register context, int index) { | 357 static Operand ContextOperand(Register context, int index) { |
362 return Operand(context, Context::SlotOffset(index)); | 358 return Operand(context, Context::SlotOffset(index)); |
363 } | 359 } |
364 | 360 |
365 private: | 361 private: |
| 362 // Type of a member function that generates inline code for a native function. |
| 363 typedef void (CodeGenerator::*InlineFunctionGenerator) |
| 364 (ZoneList<Expression*>*); |
| 365 |
| 366 static const InlineFunctionGenerator kInlineFunctionGenerators[]; |
| 367 |
366 // Construction/Destruction | 368 // Construction/Destruction |
367 explicit CodeGenerator(MacroAssembler* masm); | 369 explicit CodeGenerator(MacroAssembler* masm); |
368 | 370 |
369 // Accessors | 371 // Accessors |
370 inline bool is_eval(); | 372 inline bool is_eval(); |
371 inline Scope* scope(); | 373 inline Scope* scope(); |
372 | 374 |
373 // Generating deferred code. | 375 // Generating deferred code. |
374 void ProcessDeferred(); | 376 void ProcessDeferred(); |
375 | 377 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 // An optimized implementation of expressions of the form | 619 // An optimized implementation of expressions of the form |
618 // x.apply(y, arguments). We call x the applicand and y the receiver. | 620 // x.apply(y, arguments). We call x the applicand and y the receiver. |
619 // The optimization avoids allocating an arguments object if possible. | 621 // The optimization avoids allocating an arguments object if possible. |
620 void CallApplyLazy(Expression* applicand, | 622 void CallApplyLazy(Expression* applicand, |
621 Expression* receiver, | 623 Expression* receiver, |
622 VariableProxy* arguments, | 624 VariableProxy* arguments, |
623 int position); | 625 int position); |
624 | 626 |
625 void CheckStack(); | 627 void CheckStack(); |
626 | 628 |
627 struct InlineRuntimeLUT { | 629 static InlineFunctionGenerator FindInlineFunctionGenerator( |
628 void (CodeGenerator::*method)(ZoneList<Expression*>*); | 630 Runtime::FunctionId function_id); |
629 const char* name; | |
630 int nargs; | |
631 }; | |
632 | 631 |
633 static InlineRuntimeLUT* FindInlineRuntimeLUT(Handle<String> name); | |
634 bool CheckForInlineRuntimeCall(CallRuntime* node); | 632 bool CheckForInlineRuntimeCall(CallRuntime* node); |
635 | 633 |
636 void ProcessDeclarations(ZoneList<Declaration*>* declarations); | 634 void ProcessDeclarations(ZoneList<Declaration*>* declarations); |
637 | 635 |
638 static Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop); | 636 static Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop); |
639 | 637 |
640 static Handle<Code> ComputeKeyedCallInitialize(int argc, InLoopFlag in_loop); | 638 static Handle<Code> ComputeKeyedCallInitialize(int argc, InLoopFlag in_loop); |
641 | 639 |
642 // Declare global variables and functions in the given array of | 640 // Declare global variables and functions in the given array of |
643 // name/value pairs. | 641 // name/value pairs. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 // function_return_ does not jump to the true function return, but rather | 783 // function_return_ does not jump to the true function return, but rather |
786 // to some unlinking code). | 784 // to some unlinking code). |
787 bool function_return_is_shadowed_; | 785 bool function_return_is_shadowed_; |
788 | 786 |
789 // True when we are in code that expects the virtual frame to be fully | 787 // True when we are in code that expects the virtual frame to be fully |
790 // spilled. Some virtual frame function are disabled in DEBUG builds when | 788 // spilled. Some virtual frame function are disabled in DEBUG builds when |
791 // called from spilled code, because they do not leave the virtual frame | 789 // called from spilled code, because they do not leave the virtual frame |
792 // in a spilled state. | 790 // in a spilled state. |
793 bool in_spilled_code_; | 791 bool in_spilled_code_; |
794 | 792 |
795 static InlineRuntimeLUT kInlineRuntimeLUT[]; | |
796 | |
797 friend class VirtualFrame; | 793 friend class VirtualFrame; |
798 friend class JumpTarget; | 794 friend class JumpTarget; |
799 friend class Reference; | 795 friend class Reference; |
800 friend class Result; | 796 friend class Result; |
801 friend class FastCodeGenerator; | 797 friend class FastCodeGenerator; |
802 friend class FullCodeGenerator; | 798 friend class FullCodeGenerator; |
803 friend class FullCodeGenSyntaxChecker; | 799 friend class FullCodeGenSyntaxChecker; |
804 | 800 |
805 friend class CodeGeneratorPatcher; // Used in test-log-stack-tracer.cc | 801 friend class CodeGeneratorPatcher; // Used in test-log-stack-tracer.cc |
806 | 802 |
807 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); | 803 DISALLOW_COPY_AND_ASSIGN(CodeGenerator); |
808 }; | 804 }; |
809 | 805 |
810 | 806 |
811 } } // namespace v8::internal | 807 } } // namespace v8::internal |
812 | 808 |
813 #endif // V8_IA32_CODEGEN_IA32_H_ | 809 #endif // V8_IA32_CODEGEN_IA32_H_ |
OLD | NEW |