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

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

Issue 646019: Temporarily move the ia32 fast code generator into the platform-specific dire... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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/fast-codegen.h ('k') | src/ia32/fast-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28 #ifndef V8_FAST_CODEGEN_IA32_H_
29 #define V8_FAST_CODEGEN_IA32_H_
30
31 namespace v8 {
32 namespace internal {
33
34 class FastCodeGenSyntaxChecker: public AstVisitor {
35 public:
36 explicit FastCodeGenSyntaxChecker()
37 : info_(NULL), has_supported_syntax_(true) {
38 }
39
40 void Check(CompilationInfo* info);
41
42 CompilationInfo* info() { return info_; }
43 bool has_supported_syntax() { return has_supported_syntax_; }
44
45 private:
46 void VisitDeclarations(ZoneList<Declaration*>* decls);
47 void VisitStatements(ZoneList<Statement*>* stmts);
48
49 // AST node visit functions.
50 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
51 AST_NODE_LIST(DECLARE_VISIT)
52 #undef DECLARE_VISIT
53
54 CompilationInfo* info_;
55 bool has_supported_syntax_;
56
57 DISALLOW_COPY_AND_ASSIGN(FastCodeGenSyntaxChecker);
58 };
59
60
61 class FastCodeGenerator: public AstVisitor {
62 public:
63 explicit FastCodeGenerator(MacroAssembler* masm)
64 : masm_(masm), info_(NULL), destination_(no_reg), smi_bits_(0) {
65 }
66
67 static Handle<Code> MakeCode(CompilationInfo* info);
68
69 void Generate(CompilationInfo* compilation_info);
70
71 private:
72 MacroAssembler* masm() { return masm_; }
73 CompilationInfo* info() { return info_; }
74 Label* bailout() { return &bailout_; }
75
76 Register destination() { return destination_; }
77 void set_destination(Register reg) { destination_ = reg; }
78
79 FunctionLiteral* function() { return info_->function(); }
80 Scope* scope() { return info_->scope(); }
81
82 // Platform-specific fixed registers, all guaranteed distinct.
83 Register accumulator0();
84 Register accumulator1();
85 Register scratch0();
86 Register scratch1();
87 Register receiver_reg();
88 Register context_reg();
89
90 Register other_accumulator(Register reg) {
91 ASSERT(reg.is(accumulator0()) || reg.is(accumulator1()));
92 return (reg.is(accumulator0())) ? accumulator1() : accumulator0();
93 }
94
95 // Flags are true if the respective register is statically known to hold a
96 // smi. We do not track every register, only the accumulator registers.
97 bool is_smi(Register reg) {
98 ASSERT(!reg.is(no_reg));
99 return (smi_bits_ & reg.bit()) != 0;
100 }
101 void set_as_smi(Register reg) {
102 ASSERT(!reg.is(no_reg));
103 smi_bits_ = smi_bits_ | reg.bit();
104 }
105 void clear_as_smi(Register reg) {
106 ASSERT(!reg.is(no_reg));
107 smi_bits_ = smi_bits_ & ~reg.bit();
108 }
109
110 // AST node visit functions.
111 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
112 AST_NODE_LIST(DECLARE_VISIT)
113 #undef DECLARE_VISIT
114
115 // Emit code to load the receiver from the stack into receiver_reg.
116 void EmitLoadReceiver();
117
118 // Emit code to load a global variable directly from a global property
119 // cell into the destination register.
120 void EmitGlobalVariableLoad(Handle<Object> cell);
121
122 // Emit a store to an own property of this. The stored value is expected
123 // in accumulator0 and the receiver in receiver_reg. The receiver
124 // register is preserved and the result (the stored value) is left in the
125 // destination register.
126 void EmitThisPropertyStore(Handle<String> name);
127
128 // Emit a load from an own property of this. The receiver is expected in
129 // receiver_reg. The receiver register is preserved and the result is
130 // left in the destination register.
131 void EmitThisPropertyLoad(Handle<String> name);
132
133 // Emit a bitwise or operation. The left operand is in accumulator1 and
134 // the right is in accumulator0. The result should be left in the
135 // destination register.
136 void EmitBitOr();
137
138 MacroAssembler* masm_;
139 CompilationInfo* info_;
140 Label bailout_;
141 Register destination_;
142 uint32_t smi_bits_;
143
144 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator);
145 };
146
147
148 } } // namespace v8::internal
149
150 #endif // V8_FAST_CODEGEN_IA32_H_
OLDNEW
« no previous file with comments | « src/fast-codegen.h ('k') | src/ia32/fast-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698