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

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

Issue 1323463005: [Interpreter] Add support for JS calls. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add VisitCall to bytecode-generator 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 335 }
336 } 336 }
337 337
338 338
339 void BytecodeGenerator::VisitYield(Yield* expr) { UNIMPLEMENTED(); } 339 void BytecodeGenerator::VisitYield(Yield* expr) { UNIMPLEMENTED(); }
340 340
341 341
342 void BytecodeGenerator::VisitThrow(Throw* expr) { UNIMPLEMENTED(); } 342 void BytecodeGenerator::VisitThrow(Throw* expr) { UNIMPLEMENTED(); }
343 343
344 344
345 void BytecodeGenerator::VisitProperty(Property* expr) { 345 void BytecodeGenerator::VisitPropertyLoad(Register obj, Property* expr) {
346 LhsKind property_kind = Property::GetAssignType(expr); 346 LhsKind property_kind = Property::GetAssignType(expr);
347 FeedbackVectorICSlot slot = expr->PropertyFeedbackSlot(); 347 FeedbackVectorICSlot slot = expr->PropertyFeedbackSlot();
348 switch (property_kind) { 348 switch (property_kind) {
349 case VARIABLE: 349 case VARIABLE:
350 UNREACHABLE(); 350 UNREACHABLE();
351 break;
352 case NAMED_PROPERTY: { 351 case NAMED_PROPERTY: {
353 TemporaryRegisterScope temporary_register_scope(&builder_);
354 Register obj = temporary_register_scope.NewRegister();
355 Visit(expr->obj());
356 builder().StoreAccumulatorInRegister(obj);
357 builder().LoadLiteral(expr->key()->AsLiteral()->AsPropertyName()); 352 builder().LoadLiteral(expr->key()->AsLiteral()->AsPropertyName());
358 builder().LoadNamedProperty(obj, feedback_index(slot), language_mode()); 353 builder().LoadNamedProperty(obj, feedback_index(slot), language_mode());
359 break; 354 break;
360 } 355 }
361 case KEYED_PROPERTY: { 356 case KEYED_PROPERTY: {
362 TemporaryRegisterScope temporary_register_scope(&builder_);
363 Register obj = temporary_register_scope.NewRegister();
364 Visit(expr->obj());
365 builder().StoreAccumulatorInRegister(obj); 357 builder().StoreAccumulatorInRegister(obj);
366 Visit(expr->key()); 358 Visit(expr->key());
367 builder().LoadKeyedProperty(obj, feedback_index(slot), language_mode()); 359 builder().LoadKeyedProperty(obj, feedback_index(slot), language_mode());
368 break; 360 break;
369 } 361 }
370 case NAMED_SUPER_PROPERTY: 362 case NAMED_SUPER_PROPERTY:
371 case KEYED_SUPER_PROPERTY: 363 case KEYED_SUPER_PROPERTY:
372 UNIMPLEMENTED(); 364 UNIMPLEMENTED();
373 } 365 }
374 } 366 }
375 367
376 368
377 void BytecodeGenerator::VisitCall(Call* expr) { UNIMPLEMENTED(); } 369 void BytecodeGenerator::VisitProperty(Property* expr) {
370 TemporaryRegisterScope temporary_register_scope(&builder_);
371 Register obj = temporary_register_scope.NewRegister();
372 Visit(expr->obj());
373 builder().StoreAccumulatorInRegister(obj);
374 VisitPropertyLoad(obj, expr);
375 }
376
377
378 void BytecodeGenerator::VisitCall(Call* expr) {
379 Expression* callee_expr = expr->expression();
380 Call::CallType call_type = expr->GetCallType(isolate());
381
382 // Prepare the callee and the receiver to the function call. This depends on
383 // the semantics of the underlying call type.
384 TemporaryRegisterScope temporary_register_scope(&builder_);
385 Register callee = temporary_register_scope.NewRegister();
386 Register receiver = temporary_register_scope.NewRegister();
387
388 switch (call_type) {
389 case Call::PROPERTY_CALL: {
390 Property* property = callee_expr->AsProperty();
391 if (property->IsSuperAccess()) {
392 UNIMPLEMENTED();
393 }
394 Visit(property->obj());
395 builder().StoreAccumulatorInRegister(receiver);
396 // Perform a property load of the callee.
397 VisitPropertyLoad(receiver, property);
398 builder().StoreAccumulatorInRegister(callee);
399 break;
400 }
401 case Call::GLOBAL_CALL:
402 case Call::LOOKUP_SLOT_CALL:
403 case Call::SUPER_CALL:
404 case Call::POSSIBLY_EVAL_CALL:
405 case Call::OTHER_CALL:
406 UNIMPLEMENTED();
407 }
408
409 // Evaluate all arguments to the function call and store in sequential
410 // registers.
411 ZoneList<Expression*>* args = expr->arguments();
412 for (int i = 0; i < args->length(); ++i) {
413 Visit(args->at(i));
414 Register arg = temporary_register_scope.NewRegister();
415 DCHECK(arg.index() - i == receiver.index() + 1);
416 builder().StoreAccumulatorInRegister(arg);
417 }
418
419 // TODO(rmcilroy): Deal with possible direct eval here?
420 // TODO(rmcilroy): Use CallIC to allow call type feedback.
421 builder().Call(callee, receiver, args->length());
422 }
378 423
379 424
380 void BytecodeGenerator::VisitCallNew(CallNew* expr) { UNIMPLEMENTED(); } 425 void BytecodeGenerator::VisitCallNew(CallNew* expr) { UNIMPLEMENTED(); }
381 426
382 427
383 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { UNIMPLEMENTED(); } 428 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { UNIMPLEMENTED(); }
384 429
385 430
386 void BytecodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { 431 void BytecodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
387 UNIMPLEMENTED(); 432 UNIMPLEMENTED();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 501 }
457 502
458 503
459 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const { 504 int BytecodeGenerator::feedback_index(FeedbackVectorICSlot slot) const {
460 return info()->feedback_vector()->GetIndex(slot); 505 return info()->feedback_vector()->GetIndex(slot);
461 } 506 }
462 507
463 } // namespace interpreter 508 } // namespace interpreter
464 } // namespace internal 509 } // namespace internal
465 } // namespace v8 510 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698