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

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

Issue 549158: Refactor the selection of code generator (toplevel or optimizing) and... (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/flag-definitions.h » ('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 #include "v8.h"
29
30 #include "fast-codegen.h"
31 #include "scopes.h"
32
33 namespace v8 {
34 namespace internal {
35
36 #define BAILOUT(reason) \
37 do { \
38 if (FLAG_trace_bailout) { \
39 PrintF("%s\n", reason); \
40 } \
41 has_supported_syntax_ = false; \
42 return; \
43 } while (false)
44
45
46 #define CHECK_BAILOUT \
47 do { \
48 if (!has_supported_syntax_) return; \
49 } while (false)
50
51
52 void FastCodeGenSyntaxChecker::Check(FunctionLiteral* fun) {
53 Scope* scope = fun->scope();
54
55 // We do not support stack or heap slots (both of which require
56 // allocation).
57 if (scope->num_stack_slots() > 0) {
58 BAILOUT("Function has stack-allocated locals");
59 }
60 if (scope->num_heap_slots() > 0) {
61 BAILOUT("Function has context-allocated locals");
62 }
63
64 VisitDeclarations(scope->declarations());
65 CHECK_BAILOUT;
66
67 // We do not support empty function bodies.
68 if (fun->body()->is_empty()) BAILOUT("Function has an empty body");
69 VisitStatements(fun->body());
70 }
71
72
73 void FastCodeGenSyntaxChecker::VisitDeclarations(
74 ZoneList<Declaration*>* decls) {
75 if (!decls->is_empty()) BAILOUT("Function has declarations");
76 }
77
78
79 void FastCodeGenSyntaxChecker::VisitStatements(ZoneList<Statement*>* stmts) {
80 for (int i = 0, len = stmts->length(); i < len; i++) {
81 Visit(stmts->at(i));
82 CHECK_BAILOUT;
83 }
84 }
85
86
87 void FastCodeGenSyntaxChecker::VisitDeclaration(Declaration* decl) {
88 UNREACHABLE();
89 }
90
91
92 void FastCodeGenSyntaxChecker::VisitBlock(Block* stmt) {
93 VisitStatements(stmt->statements());
94 }
95
96
97 void FastCodeGenSyntaxChecker::VisitExpressionStatement(
98 ExpressionStatement* stmt) {
99 Visit(stmt->expression());
100 }
101
102
103 void FastCodeGenSyntaxChecker::VisitEmptyStatement(EmptyStatement* stmt) {
104 // Supported.
105 }
106
107
108 void FastCodeGenSyntaxChecker::VisitIfStatement(IfStatement* stmt) {
109 BAILOUT("IfStatement");
110 }
111
112
113 void FastCodeGenSyntaxChecker::VisitContinueStatement(ContinueStatement* stmt) {
114 BAILOUT("Continuestatement");
115 }
116
117
118 void FastCodeGenSyntaxChecker::VisitBreakStatement(BreakStatement* stmt) {
119 BAILOUT("BreakStatement");
120 }
121
122
123 void FastCodeGenSyntaxChecker::VisitReturnStatement(ReturnStatement* stmt) {
124 BAILOUT("ReturnStatement");
125 }
126
127
128 void FastCodeGenSyntaxChecker::VisitWithEnterStatement(
129 WithEnterStatement* stmt) {
130 BAILOUT("WithEnterStatement");
131 }
132
133
134 void FastCodeGenSyntaxChecker::VisitWithExitStatement(WithExitStatement* stmt) {
135 BAILOUT("WithExitStatement");
136 }
137
138
139 void FastCodeGenSyntaxChecker::VisitSwitchStatement(SwitchStatement* stmt) {
140 BAILOUT("SwitchStatement");
141 }
142
143
144 void FastCodeGenSyntaxChecker::VisitDoWhileStatement(DoWhileStatement* stmt) {
145 BAILOUT("DoWhileStatement");
146 }
147
148
149 void FastCodeGenSyntaxChecker::VisitWhileStatement(WhileStatement* stmt) {
150 BAILOUT("WhileStatement");
151 }
152
153
154 void FastCodeGenSyntaxChecker::VisitForStatement(ForStatement* stmt) {
155 BAILOUT("ForStatement");
156 }
157
158
159 void FastCodeGenSyntaxChecker::VisitForInStatement(ForInStatement* stmt) {
160 BAILOUT("ForInStatement");
161 }
162
163
164 void FastCodeGenSyntaxChecker::VisitTryCatchStatement(TryCatchStatement* stmt) {
165 BAILOUT("TryCatchStatement");
166 }
167
168
169 void FastCodeGenSyntaxChecker::VisitTryFinallyStatement(
170 TryFinallyStatement* stmt) {
171 BAILOUT("TryFinallyStatement");
172 }
173
174
175 void FastCodeGenSyntaxChecker::VisitDebuggerStatement(
176 DebuggerStatement* stmt) {
177 BAILOUT("DebuggerStatement");
178 }
179
180
181 void FastCodeGenSyntaxChecker::VisitFunctionLiteral(FunctionLiteral* expr) {
182 BAILOUT("FunctionLiteral");
183 }
184
185
186 void FastCodeGenSyntaxChecker::VisitFunctionBoilerplateLiteral(
187 FunctionBoilerplateLiteral* expr) {
188 BAILOUT("FunctionBoilerplateLiteral");
189 }
190
191
192 void FastCodeGenSyntaxChecker::VisitConditional(Conditional* expr) {
193 BAILOUT("Conditional");
194 }
195
196
197 void FastCodeGenSyntaxChecker::VisitSlot(Slot* expr) {
198 UNREACHABLE();
199 }
200
201
202 void FastCodeGenSyntaxChecker::VisitVariableProxy(VariableProxy* expr) {
203 // Only global variable references are supported.
204 Variable* var = expr->var();
205 if (!var->is_global()) BAILOUT("Non-global variable");
206 }
207
208
209 void FastCodeGenSyntaxChecker::VisitLiteral(Literal* expr) {
210 BAILOUT("Literal");
211 }
212
213
214 void FastCodeGenSyntaxChecker::VisitRegExpLiteral(RegExpLiteral* expr) {
215 BAILOUT("RegExpLiteral");
216 }
217
218
219 void FastCodeGenSyntaxChecker::VisitObjectLiteral(ObjectLiteral* expr) {
220 BAILOUT("ObjectLiteral");
221 }
222
223
224 void FastCodeGenSyntaxChecker::VisitArrayLiteral(ArrayLiteral* expr) {
225 BAILOUT("ArrayLiteral");
226 }
227
228
229 void FastCodeGenSyntaxChecker::VisitCatchExtensionObject(
230 CatchExtensionObject* expr) {
231 BAILOUT("CatchExtensionObject");
232 }
233
234
235 void FastCodeGenSyntaxChecker::VisitAssignment(Assignment* expr) {
236 // Simple assignments to (named) this properties are supported.
237 if (expr->op() != Token::ASSIGN) BAILOUT("Non-simple assignment");
238
239 Property* prop = expr->target()->AsProperty();
240 if (prop == NULL) BAILOUT("Non-property assignment");
241 VariableProxy* proxy = prop->obj()->AsVariableProxy();
242 if (proxy == NULL || !proxy->var()->is_this()) {
243 BAILOUT("Non-this-property assignment");
244 }
245 if (!prop->key()->IsPropertyName()) {
246 BAILOUT("Non-named-property assignment");
247 }
248
249 Visit(expr->value());
250 }
251
252
253 void FastCodeGenSyntaxChecker::VisitThrow(Throw* expr) {
254 BAILOUT("Throw");
255 }
256
257
258 void FastCodeGenSyntaxChecker::VisitProperty(Property* expr) {
259 BAILOUT("Property");
260 }
261
262
263 void FastCodeGenSyntaxChecker::VisitCall(Call* expr) {
264 BAILOUT("Call");
265 }
266
267
268 void FastCodeGenSyntaxChecker::VisitCallNew(CallNew* expr) {
269 BAILOUT("CallNew");
270 }
271
272
273 void FastCodeGenSyntaxChecker::VisitCallRuntime(CallRuntime* expr) {
274 BAILOUT("CallRuntime");
275 }
276
277
278 void FastCodeGenSyntaxChecker::VisitUnaryOperation(UnaryOperation* expr) {
279 BAILOUT("UnaryOperation");
280 }
281
282
283 void FastCodeGenSyntaxChecker::VisitCountOperation(CountOperation* expr) {
284 BAILOUT("CountOperation");
285 }
286
287
288 void FastCodeGenSyntaxChecker::VisitBinaryOperation(BinaryOperation* expr) {
289 BAILOUT("BinaryOperation");
290 }
291
292
293 void FastCodeGenSyntaxChecker::VisitCompareOperation(CompareOperation* expr) {
294 BAILOUT("CompareOperation");
295 }
296
297
298 void FastCodeGenSyntaxChecker::VisitThisFunction(ThisFunction* expr) {
299 BAILOUT("ThisFunction");
300 }
301
302 #undef BAILOUT
303 #undef CHECK_BAILOUT
304
305
306 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/fast-codegen.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698