Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: src/fast-codegen.h

Issue 660095: Merge revision 3813 to 3930 from bleeding_edge to partial snapshots branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/execution.cc ('k') | src/fast-codegen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_FAST_CODEGEN_H_ 28 #ifndef V8_FAST_CODEGEN_H_
29 #define V8_FAST_CODEGEN_H_ 29 #define V8_FAST_CODEGEN_H_
30 30
31 #if V8_TARGET_ARCH_IA32
32 #include "ia32/fast-codegen-ia32.h"
33 #else
34
31 #include "v8.h" 35 #include "v8.h"
32 36
33 #include "ast.h" 37 #include "ast.h"
34 #include "compiler.h" 38 #include "compiler.h"
39 #include "list.h"
35 40
36 namespace v8 { 41 namespace v8 {
37 namespace internal { 42 namespace internal {
38 43
39 class FastCodeGenSyntaxChecker: public AstVisitor { 44 class FastCodeGenSyntaxChecker: public AstVisitor {
40 public: 45 public:
41 explicit FastCodeGenSyntaxChecker() 46 explicit FastCodeGenSyntaxChecker()
42 : info_(NULL), has_supported_syntax_(true) { 47 : info_(NULL), has_supported_syntax_(true) {
43 } 48 }
44 49
(...skipping 13 matching lines...) Expand all
58 63
59 CompilationInfo* info_; 64 CompilationInfo* info_;
60 bool has_supported_syntax_; 65 bool has_supported_syntax_;
61 66
62 DISALLOW_COPY_AND_ASSIGN(FastCodeGenSyntaxChecker); 67 DISALLOW_COPY_AND_ASSIGN(FastCodeGenSyntaxChecker);
63 }; 68 };
64 69
65 70
66 class FastCodeGenerator: public AstVisitor { 71 class FastCodeGenerator: public AstVisitor {
67 public: 72 public:
68 explicit FastCodeGenerator(MacroAssembler* masm) : masm_(masm), info_(NULL) {} 73 explicit FastCodeGenerator(MacroAssembler* masm)
74 : masm_(masm), info_(NULL), destination_(no_reg), smi_bits_(0) {
75 }
69 76
70 static Handle<Code> MakeCode(CompilationInfo* info); 77 static Handle<Code> MakeCode(CompilationInfo* info);
71 78
72 void Generate(CompilationInfo* compilation_info); 79 void Generate(CompilationInfo* compilation_info);
73 80
74 private: 81 private:
75 MacroAssembler* masm() { return masm_; } 82 MacroAssembler* masm() { return masm_; }
76 CompilationInfo* info() { return info_; } 83 CompilationInfo* info() { return info_; }
77 Label* bailout() { return &bailout_; } 84
85 Register destination() { return destination_; }
86 void set_destination(Register reg) { destination_ = reg; }
78 87
79 FunctionLiteral* function() { return info_->function(); } 88 FunctionLiteral* function() { return info_->function(); }
80 Scope* scope() { return info_->scope(); } 89 Scope* scope() { return info_->scope(); }
81 90
91 // Platform-specific fixed registers, all guaranteed distinct.
92 Register accumulator0();
93 Register accumulator1();
94 Register scratch0();
95 Register scratch1();
96 Register receiver_reg();
97 Register context_reg();
98
99 Register other_accumulator(Register reg) {
100 ASSERT(reg.is(accumulator0()) || reg.is(accumulator1()));
101 return (reg.is(accumulator0())) ? accumulator1() : accumulator0();
102 }
103
104 // Flags are true if the respective register is statically known to hold a
105 // smi. We do not track every register, only the accumulator registers.
106 bool is_smi(Register reg) {
107 ASSERT(!reg.is(no_reg));
108 return (smi_bits_ & reg.bit()) != 0;
109 }
110 void set_as_smi(Register reg) {
111 ASSERT(!reg.is(no_reg));
112 smi_bits_ = smi_bits_ | reg.bit();
113 }
114 void clear_as_smi(Register reg) {
115 ASSERT(!reg.is(no_reg));
116 smi_bits_ = smi_bits_ & ~reg.bit();
117 }
118
82 // AST node visit functions. 119 // AST node visit functions.
83 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); 120 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
84 AST_NODE_LIST(DECLARE_VISIT) 121 AST_NODE_LIST(DECLARE_VISIT)
85 #undef DECLARE_VISIT 122 #undef DECLARE_VISIT
86 123
87 // Emit code to load the receiver from the stack into a given register. 124 // Emit code to load the receiver from the stack into receiver_reg.
88 void EmitLoadReceiver(Register reg); 125 void EmitLoadReceiver();
89 126
90 // Emit code to check that the receiver has the same map as the 127 // Emit code to load a global variable directly from a global property
91 // compile-time receiver. Receiver is expected in {ia32-edx, x64-rdx, 128 // cell into the destination register.
92 // arm-r1}. Emit a branch to the (single) bailout label if check fails.
93 void EmitReceiverMapCheck();
94
95 // Emit code to check that the global object has the same map as the
96 // global object seen at compile time.
97 void EmitGlobalMapCheck();
98
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); 129 void EmitGlobalVariableLoad(Handle<Object> cell);
102 130
103 // Emit a store to an own property of this. The stored value is expected 131 // 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, 132 // in accumulator0 and the receiver in receiver_reg. The receiver
105 // arm-r1}. Both are preserve. 133 // register is preserved and the result (the stored value) is left in the
134 // destination register.
106 void EmitThisPropertyStore(Handle<String> name); 135 void EmitThisPropertyStore(Handle<String> name);
107 136
137 // Emit a load from an own property of this. The receiver is expected in
138 // receiver_reg. The receiver register is preserved and the result is
139 // left in the destination register.
140 void EmitThisPropertyLoad(Handle<String> name);
141
142 // Emit a bitwise or operation. The left operand is in accumulator1 and
143 // the right is in accumulator0. The result should be left in the
144 // destination register.
145 void EmitBitOr();
146
108 MacroAssembler* masm_; 147 MacroAssembler* masm_;
109
110 CompilationInfo* info_; 148 CompilationInfo* info_;
111 149 Register destination_;
112 Label bailout_; 150 uint32_t smi_bits_;
113 151
114 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator); 152 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator);
115 }; 153 };
116 154
117 155
118 } } // namespace v8::internal 156 } } // namespace v8::internal
119 157
158 #endif // V8_TARGET_ARCH_IA32
159
120 #endif // V8_FAST_CODEGEN_H_ 160 #endif // V8_FAST_CODEGEN_H_
OLDNEW
« no previous file with comments | « src/execution.cc ('k') | src/fast-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698