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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 DISALLOW_COPY_AND_ASSIGN(FastCodeGenSyntaxChecker); | 62 DISALLOW_COPY_AND_ASSIGN(FastCodeGenSyntaxChecker); |
63 }; | 63 }; |
64 | 64 |
65 | 65 |
66 class FastCodeGenerator: public AstVisitor { | 66 class FastCodeGenerator: public AstVisitor { |
67 public: | 67 public: |
68 explicit FastCodeGenerator(MacroAssembler* masm) : masm_(masm), info_(NULL) {} | 68 explicit FastCodeGenerator(MacroAssembler* masm) : masm_(masm), info_(NULL) {} |
69 | 69 |
70 static Handle<Code> MakeCode(CompilationInfo* info); | 70 static Handle<Code> MakeCode(CompilationInfo* info); |
71 | 71 |
72 void Generate(CompilationInfo* info); | 72 void Generate(CompilationInfo* compilation_info); |
73 | 73 |
74 private: | 74 private: |
75 MacroAssembler* masm() { return masm_; } | 75 MacroAssembler* masm() { return masm_; } |
| 76 CompilationInfo* info() { return info_; } |
76 Label* bailout() { return &bailout_; } | 77 Label* bailout() { return &bailout_; } |
77 | 78 |
78 bool has_receiver() { return !info_->receiver().is_null(); } | |
79 Handle<Object> receiver() { return info_->receiver(); } | |
80 bool has_this_properties() { return info_->has_this_properties(); } | |
81 FunctionLiteral* function() { return info_->function(); } | 79 FunctionLiteral* function() { return info_->function(); } |
82 Scope* scope() { return info_->scope(); } | 80 Scope* scope() { return info_->scope(); } |
83 | 81 |
84 // AST node visit functions. | 82 // AST node visit functions. |
85 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 83 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
86 AST_NODE_LIST(DECLARE_VISIT) | 84 AST_NODE_LIST(DECLARE_VISIT) |
87 #undef DECLARE_VISIT | 85 #undef DECLARE_VISIT |
88 | 86 |
89 // Emit code to load the receiver from the stack into a given register. | 87 // Emit code to load the receiver from the stack into a given register. |
90 void EmitLoadReceiver(Register reg); | 88 void EmitLoadReceiver(Register reg); |
91 | 89 |
92 // Emit code to check that the receiver has the same map as the | 90 // Emit code to check that the receiver has the same map as the |
93 // compile-time receiver. Receiver is expected in {ia32-edx, x64-rdx, | 91 // compile-time receiver. Receiver is expected in {ia32-edx, x64-rdx, |
94 // arm-r1}. Emit a branch to the (single) bailout label if check fails. | 92 // arm-r1}. Emit a branch to the (single) bailout label if check fails. |
95 void EmitReceiverMapCheck(); | 93 void EmitReceiverMapCheck(); |
96 | 94 |
97 // Emit code to load a global variable value into {is32-eax, x64-rax, | 95 // Emit code to check that the global object has the same map as the |
98 // arm-r0}. Register {ia32-edx, x64-rdx, arm-r1} is preserved if it is | 96 // global object seen at compile time. |
99 // holding the receiver and {is32-ecx, x64-rcx, arm-r2} is always | 97 void EmitGlobalMapCheck(); |
100 // clobbered. | 98 |
101 void EmitGlobalVariableLoad(Handle<String> name); | 99 // Emit code to load a global variable directly from a global |
| 100 // property cell into {ia32-eax, x64-rax, arm-r0}. |
| 101 void EmitGlobalVariableLoad(Handle<Object> cell); |
102 | 102 |
103 // Emit a store to an own property of this. The stored value is expected | 103 // Emit a store to an own property of this. The stored value is expected |
104 // in {ia32-eax, x64-rax, arm-r0} and the receiver in {is32-edx, x64-rdx, | 104 // in {ia32-eax, x64-rax, arm-r0} and the receiver in {is32-edx, x64-rdx, |
105 // arm-r1}. Both are preserve. | 105 // arm-r1}. Both are preserve. |
106 void EmitThisPropertyStore(Handle<String> name); | 106 void EmitThisPropertyStore(Handle<String> name); |
107 | 107 |
108 MacroAssembler* masm_; | 108 MacroAssembler* masm_; |
109 | 109 |
110 CompilationInfo* info_; | 110 CompilationInfo* info_; |
111 | 111 |
112 Label bailout_; | 112 Label bailout_; |
113 | 113 |
114 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator); | 114 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator); |
115 }; | 115 }; |
116 | 116 |
117 | 117 |
118 } } // namespace v8::internal | 118 } } // namespace v8::internal |
119 | 119 |
120 #endif // V8_FAST_CODEGEN_H_ | 120 #endif // V8_FAST_CODEGEN_H_ |
OLD | NEW |