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

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

Issue 553116: Enable references and assignments to lookup slots in the toplevel code... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 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/full-codegen.h ('k') | src/ia32/full-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
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 CHECK_BAILOUT; 126 CHECK_BAILOUT;
127 Visit(stmt->else_statement()); 127 Visit(stmt->else_statement());
128 } 128 }
129 129
130 130
131 void FullCodeGenSyntaxChecker::VisitContinueStatement(ContinueStatement* stmt) { 131 void FullCodeGenSyntaxChecker::VisitContinueStatement(ContinueStatement* stmt) {
132 // Supported. 132 // Supported.
133 } 133 }
134 134
135 135
136 void FullCodeGenSyntaxChecker::VisitBreakStatement(BreakStatement* stmt) {} 136 void FullCodeGenSyntaxChecker::VisitBreakStatement(BreakStatement* stmt) {
137 // Supported.
138 }
137 139
138 140
139 void FullCodeGenSyntaxChecker::VisitReturnStatement(ReturnStatement* stmt) { 141 void FullCodeGenSyntaxChecker::VisitReturnStatement(ReturnStatement* stmt) {
140 Visit(stmt->expression()); 142 Visit(stmt->expression());
141 } 143 }
142 144
143 145
144 void FullCodeGenSyntaxChecker::VisitWithEnterStatement( 146 void FullCodeGenSyntaxChecker::VisitWithEnterStatement(
145 WithEnterStatement* stmt) { 147 WithEnterStatement* stmt) {
146 Visit(stmt->expression()); 148 Visit(stmt->expression());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 Visit(expr->else_expression()); 236 Visit(expr->else_expression());
235 } 237 }
236 238
237 239
238 void FullCodeGenSyntaxChecker::VisitSlot(Slot* expr) { 240 void FullCodeGenSyntaxChecker::VisitSlot(Slot* expr) {
239 UNREACHABLE(); 241 UNREACHABLE();
240 } 242 }
241 243
242 244
243 void FullCodeGenSyntaxChecker::VisitVariableProxy(VariableProxy* expr) { 245 void FullCodeGenSyntaxChecker::VisitVariableProxy(VariableProxy* expr) {
244 Variable* var = expr->var(); 246 // Supported.
245 if (!var->is_global()) {
246 Slot* slot = var->slot();
247 if (slot != NULL) {
248 Slot::Type type = slot->type();
249 // When LOOKUP slots are enabled, some currently dead code
250 // implementing unary typeof will become live.
251 if (type == Slot::LOOKUP) {
252 BAILOUT("Lookup slot");
253 }
254 } else {
255 // If not global or a slot, it is a parameter rewritten to an explicit
256 // property reference on the (shadow) arguments object.
257 #ifdef DEBUG
258 Property* property = var->AsProperty();
259 ASSERT_NOT_NULL(property);
260 Variable* object = property->obj()->AsVariableProxy()->AsVariable();
261 ASSERT_NOT_NULL(object);
262 ASSERT_NOT_NULL(object->slot());
263 ASSERT_NOT_NULL(property->key()->AsLiteral());
264 ASSERT(property->key()->AsLiteral()->handle()->IsSmi());
265 #endif
266 }
267 }
268 } 247 }
269 248
270 249
271 void FullCodeGenSyntaxChecker::VisitLiteral(Literal* expr) { 250 void FullCodeGenSyntaxChecker::VisitLiteral(Literal* expr) {
272 // Supported. 251 // Supported.
273 } 252 }
274 253
275 254
276 void FullCodeGenSyntaxChecker::VisitRegExpLiteral(RegExpLiteral* expr) { 255 void FullCodeGenSyntaxChecker::VisitRegExpLiteral(RegExpLiteral* expr) {
277 // Supported. 256 // Supported.
(...skipping 28 matching lines...) Expand all
306 285
307 void FullCodeGenSyntaxChecker::VisitCatchExtensionObject( 286 void FullCodeGenSyntaxChecker::VisitCatchExtensionObject(
308 CatchExtensionObject* expr) { 287 CatchExtensionObject* expr) {
309 Visit(expr->key()); 288 Visit(expr->key());
310 CHECK_BAILOUT; 289 CHECK_BAILOUT;
311 Visit(expr->value()); 290 Visit(expr->value());
312 } 291 }
313 292
314 293
315 void FullCodeGenSyntaxChecker::VisitAssignment(Assignment* expr) { 294 void FullCodeGenSyntaxChecker::VisitAssignment(Assignment* expr) {
316 // We support plain non-compound assignments to properties, parameters and
317 // non-context (stack-allocated) locals, and global variables.
318 Token::Value op = expr->op(); 295 Token::Value op = expr->op();
319 if (op == Token::INIT_CONST) BAILOUT("initialize constant"); 296 if (op == Token::INIT_CONST) BAILOUT("initialize constant");
320 297
321 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); 298 Variable* var = expr->target()->AsVariableProxy()->AsVariable();
322 Property* prop = expr->target()->AsProperty(); 299 Property* prop = expr->target()->AsProperty();
323 ASSERT(var == NULL || prop == NULL); 300 ASSERT(var == NULL || prop == NULL);
324 if (var != NULL) { 301 if (var != NULL) {
325 if (var->mode() == Variable::CONST) { 302 if (var->mode() == Variable::CONST) BAILOUT("Assignment to const");
326 BAILOUT("Assignment to const"); 303 // All other variables are supported.
327 }
328 // All global variables are supported.
329 if (!var->is_global()) {
330 ASSERT(var->slot() != NULL);
331 Slot::Type type = var->slot()->type();
332 if (type == Slot::LOOKUP) {
333 BAILOUT("Lookup slot");
334 }
335 }
336 } else if (prop != NULL) { 304 } else if (prop != NULL) {
337 Visit(prop->obj()); 305 Visit(prop->obj());
338 CHECK_BAILOUT; 306 CHECK_BAILOUT;
339 Visit(prop->key()); 307 Visit(prop->key());
340 CHECK_BAILOUT; 308 CHECK_BAILOUT;
341 } else { 309 } else {
342 // This is a throw reference error. 310 // This is a throw reference error.
343 BAILOUT("non-variable/non-property assignment"); 311 BAILOUT("non-variable/non-property assignment");
344 } 312 }
345 313
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 1036
1069 1037
1070 void FullCodeGenerator::VisitLiteral(Literal* expr) { 1038 void FullCodeGenerator::VisitLiteral(Literal* expr) {
1071 Comment cmnt(masm_, "[ Literal"); 1039 Comment cmnt(masm_, "[ Literal");
1072 Apply(context_, expr); 1040 Apply(context_, expr);
1073 } 1041 }
1074 1042
1075 1043
1076 void FullCodeGenerator::VisitAssignment(Assignment* expr) { 1044 void FullCodeGenerator::VisitAssignment(Assignment* expr) {
1077 Comment cmnt(masm_, "[ Assignment"); 1045 Comment cmnt(masm_, "[ Assignment");
1046 ASSERT(expr->op() != Token::INIT_CONST);
1078 // Left-hand side can only be a property, a global or a (parameter or local) 1047 // Left-hand side can only be a property, a global or a (parameter or local)
1079 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY. 1048 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
1080 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; 1049 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
1081 LhsKind assign_type = VARIABLE; 1050 LhsKind assign_type = VARIABLE;
1082 Property* prop = expr->target()->AsProperty(); 1051 Property* prop = expr->target()->AsProperty();
1083 if (prop != NULL) { 1052 if (prop != NULL) {
1084 assign_type = 1053 assign_type =
1085 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; 1054 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
1086 } 1055 }
1087 1056
(...skipping 30 matching lines...) Expand all
1118 __ push(result_register()); 1087 __ push(result_register());
1119 break; 1088 break;
1120 } 1089 }
1121 location_ = saved_location; 1090 location_ = saved_location;
1122 } 1091 }
1123 1092
1124 // Evaluate RHS expression. 1093 // Evaluate RHS expression.
1125 Expression* rhs = expr->value(); 1094 Expression* rhs = expr->value();
1126 VisitForValue(rhs, kAccumulator); 1095 VisitForValue(rhs, kAccumulator);
1127 1096
1128 // If we have a compount assignment: Apply operator. 1097 // If we have a compound assignment: Apply operator.
1129 if (expr->is_compound()) { 1098 if (expr->is_compound()) {
1130 Location saved_location = location_; 1099 Location saved_location = location_;
1131 location_ = kAccumulator; 1100 location_ = kAccumulator;
1132 EmitBinaryOp(expr->binary_op(), Expression::kValue); 1101 EmitBinaryOp(expr->binary_op(), Expression::kValue);
1133 location_ = saved_location; 1102 location_ = saved_location;
1134 } 1103 }
1135 1104
1136 // Record source position before possible IC call. 1105 // Record source position before possible IC call.
1137 SetSourcePosition(expr->position()); 1106 SetSourcePosition(expr->position());
1138 1107
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 __ Drop(stack_depth); 1155 __ Drop(stack_depth);
1187 __ PopTryHandler(); 1156 __ PopTryHandler();
1188 return 0; 1157 return 0;
1189 } 1158 }
1190 1159
1191 1160
1192 #undef __ 1161 #undef __
1193 1162
1194 1163
1195 } } // namespace v8::internal 1164 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698