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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 1319833004: [Interpreter] Add support for property store operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_implicit_ret
Patch Set: Created 5 years, 3 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 case VariableLocation::UNALLOCATED: 263 case VariableLocation::UNALLOCATED:
264 case VariableLocation::CONTEXT: 264 case VariableLocation::CONTEXT:
265 case VariableLocation::LOOKUP: 265 case VariableLocation::LOOKUP:
266 UNIMPLEMENTED(); 266 UNIMPLEMENTED();
267 } 267 }
268 } 268 }
269 269
270 270
271 void BytecodeGenerator::VisitAssignment(Assignment* expr) { 271 void BytecodeGenerator::VisitAssignment(Assignment* expr) {
272 DCHECK(expr->target()->IsValidReferenceExpression()); 272 DCHECK(expr->target()->IsValidReferenceExpression());
273 TemporaryRegisterScope temporary_register_scope(&builder_);
274 Register object, key;
273 275
274 // Left-hand side can only be a property, a global or a variable slot. 276 // Left-hand side can only be a property, a global or a variable slot.
275 Property* property = expr->target()->AsProperty(); 277 Property* property = expr->target()->AsProperty();
276 LhsKind assign_type = Property::GetAssignType(property); 278 LhsKind assign_type = Property::GetAssignType(property);
277 279
278 DCHECK(!expr->is_compound()); 280 // Evaluate LHS expression.
279 Visit(expr->value()); 281 switch (assign_type) {
282 case VARIABLE:
283 // Nothing to do to evaluate variable assignment LHS.
284 break;
285 case NAMED_PROPERTY:
286 object = temporary_register_scope.NewRegister();
287 key = temporary_register_scope.NewRegister();
288 Visit(property->obj());
289 builder().StoreAccumulatorInRegister(object);
290 builder().LoadLiteral(property->key()->AsLiteral()->AsPropertyName());
291 builder().StoreAccumulatorInRegister(key);
292 break;
293 case KEYED_PROPERTY:
294 object = temporary_register_scope.NewRegister();
295 key = temporary_register_scope.NewRegister();
296 Visit(property->obj());
297 builder().StoreAccumulatorInRegister(object);
298 Visit(property->key());
299 builder().StoreAccumulatorInRegister(key);
300 break;
301 case NAMED_SUPER_PROPERTY:
302 case KEYED_SUPER_PROPERTY:
303 UNIMPLEMENTED();
304 }
280 305
306 // Evaluate the value and potentially handle compound assignments by loading
307 // the left-hand side value and performing a binary operation.
308 if (expr->is_compound()) {
309 UNIMPLEMENTED();
310 } else {
311 Visit(expr->value());
312 }
313
314 // Store the value.
315 FeedbackVectorICSlot slot = expr->AssignmentSlot();
281 switch (assign_type) { 316 switch (assign_type) {
282 case VARIABLE: { 317 case VARIABLE: {
283 Variable* variable = expr->target()->AsVariableProxy()->var(); 318 Variable* variable = expr->target()->AsVariableProxy()->var();
284 DCHECK(variable->location() == VariableLocation::LOCAL); 319 DCHECK(variable->location() == VariableLocation::LOCAL);
285 Register destination(variable->index()); 320 Register destination(variable->index());
286 builder().StoreAccumulatorInRegister(destination); 321 builder().StoreAccumulatorInRegister(destination);
287 break; 322 break;
288 } 323 }
289 case NAMED_PROPERTY: 324 case NAMED_PROPERTY:
325 builder().StoreNamedProperty(object, key, feedback_index(slot),
326 language_mode());
327 break;
290 case KEYED_PROPERTY: 328 case KEYED_PROPERTY:
329 builder().StoreKeyedProperty(object, key, feedback_index(slot),
330 language_mode());
331 break;
291 case NAMED_SUPER_PROPERTY: 332 case NAMED_SUPER_PROPERTY:
292 case KEYED_SUPER_PROPERTY: 333 case KEYED_SUPER_PROPERTY:
293 UNIMPLEMENTED(); 334 UNIMPLEMENTED();
294 } 335 }
295 } 336 }
296 337
297 338
298 void BytecodeGenerator::VisitYield(Yield* expr) { UNIMPLEMENTED(); } 339 void BytecodeGenerator::VisitYield(Yield* expr) { UNIMPLEMENTED(); }
299 340
300 341
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 456 }
416 457
417 458
418 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const { 459 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const {
419 return info()->feedback_vector()->GetIndex(slot); 460 return info()->feedback_vector()->GetIndex(slot);
420 } 461 }
421 462
422 } // namespace interpreter 463 } // namespace interpreter
423 } // namespace internal 464 } // namespace internal
424 } // namespace v8 465 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698