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

Side by Side Diff: src/interpreter/interpreter.cc

Issue 1390483002: [Interpreter] Unary operators - typeof, void, and logical not. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporate review comments on patch set 3. Created 5 years, 2 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
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/objects.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 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/interpreter.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler.h" 8 #include "src/compiler.h"
9 #include "src/compiler/interpreter-assembler.h" 9 #include "src/compiler/interpreter-assembler.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 328
329 // Mod <src> 329 // Mod <src>
330 // 330 //
331 // Modulo register <src> by accumulator. 331 // Modulo register <src> by accumulator.
332 void Interpreter::DoMod(compiler::InterpreterAssembler* assembler) { 332 void Interpreter::DoMod(compiler::InterpreterAssembler* assembler) {
333 DoBinaryOp(Runtime::kModulus, assembler); 333 DoBinaryOp(Runtime::kModulus, assembler);
334 } 334 }
335 335
336 336
337 // LogicalNot
338 //
339 // Perform logical-not on the accumulator, first casting the
340 // accumulator to a boolean value if required.
341 void Interpreter::DoLogicalNot(compiler::InterpreterAssembler* assembler) {
342 Node* accumulator = __ GetAccumulator();
343 Node* result = __ CallRuntime(Runtime::kInterpreterLogicalNot, accumulator);
344 __ SetAccumulator(result);
345 __ Dispatch();
346 }
347
348
349 // TypeOf
350 //
351 // Load the accumulator with the string representating type of the
352 // object in the accumulator.
353 void Interpreter::DoTypeOf(compiler::InterpreterAssembler* assembler) {
354 Node* accumulator = __ GetAccumulator();
355 Node* result = __ CallRuntime(Runtime::kInterpreterTypeOf, accumulator);
356 __ SetAccumulator(result);
357 __ Dispatch();
358 }
359
360
337 // Call <callable> <receiver> <arg_count> 361 // Call <callable> <receiver> <arg_count>
338 // 362 //
339 // Call a JSfunction or Callable in |callable| with receiver and |arg_count| 363 // Call a JSfunction or Callable in |callable| with the |receiver| and
340 // arguments in subsequent registers. 364 // |arg_count| arguments in subsequent registers.
341 void Interpreter::DoCall(compiler::InterpreterAssembler* assembler) { 365 void Interpreter::DoCall(compiler::InterpreterAssembler* assembler) {
342 Node* function_reg = __ BytecodeOperandReg8(0); 366 Node* function_reg = __ BytecodeOperandReg8(0);
343 Node* function = __ LoadRegister(function_reg); 367 Node* function = __ LoadRegister(function_reg);
344 Node* receiver_reg = __ BytecodeOperandReg8(1); 368 Node* receiver_reg = __ BytecodeOperandReg8(1);
345 Node* first_arg = __ RegisterLocation(receiver_reg); 369 Node* first_arg = __ RegisterLocation(receiver_reg);
346 Node* args_count = __ BytecodeOperandCount8(2); 370 Node* args_count = __ BytecodeOperandCount8(2);
347 Node* result = __ CallJS(function, first_arg, args_count); 371 Node* result = __ CallJS(function, first_arg, args_count);
348 __ SetAccumulator(result); 372 __ SetAccumulator(result);
349 __ Dispatch(); 373 __ Dispatch();
350 } 374 }
351 375
352 376
353 // CallRuntime <function_id> <first_arg> <arg_count> 377 // CallRuntime <function_id> <first_arg> <arg_count>
354 // 378 //
355 // Call the runtime function |function_id| with first argument in register 379 // Call the runtime function |function_id| with the first argument in
356 // |first_arg| and |arg_count| arguments in subsequent registers. 380 // register |first_arg| and |arg_count| arguments in subsequent
381 // registers.
357 void Interpreter::DoCallRuntime(compiler::InterpreterAssembler* assembler) { 382 void Interpreter::DoCallRuntime(compiler::InterpreterAssembler* assembler) {
358 Node* function_id = __ BytecodeOperandIdx16(0); 383 Node* function_id = __ BytecodeOperandIdx16(0);
359 Node* first_arg_reg = __ BytecodeOperandReg8(1); 384 Node* first_arg_reg = __ BytecodeOperandReg8(1);
360 Node* first_arg = __ RegisterLocation(first_arg_reg); 385 Node* first_arg = __ RegisterLocation(first_arg_reg);
361 Node* args_count = __ BytecodeOperandCount8(2); 386 Node* args_count = __ BytecodeOperandCount8(2);
362 Node* result = __ CallRuntime(function_id, first_arg, args_count); 387 Node* result = __ CallRuntime(function_id, first_arg, args_count);
363 __ SetAccumulator(result); 388 __ SetAccumulator(result);
364 __ Dispatch(); 389 __ Dispatch();
365 } 390 }
366 391
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // referenced by the accumulator. 475 // referenced by the accumulator.
451 void Interpreter::DoTestInstanceOf(compiler::InterpreterAssembler* assembler) { 476 void Interpreter::DoTestInstanceOf(compiler::InterpreterAssembler* assembler) {
452 DoBinaryOp(Runtime::kInstanceOf, assembler); 477 DoBinaryOp(Runtime::kInstanceOf, assembler);
453 } 478 }
454 479
455 480
456 // ToBoolean 481 // ToBoolean
457 // 482 //
458 // Cast the object referenced by the accumulator to a boolean. 483 // Cast the object referenced by the accumulator to a boolean.
459 void Interpreter::DoToBoolean(compiler::InterpreterAssembler* assembler) { 484 void Interpreter::DoToBoolean(compiler::InterpreterAssembler* assembler) {
460 // TODO(oth): The next CL for test operations has interpreter specific 485 Node* accumulator = __ GetAccumulator();
461 // runtime calls. This looks like another candidate. 486 Node* result = __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator);
487 __ SetAccumulator(result);
462 __ Dispatch(); 488 __ Dispatch();
463 } 489 }
464 490
465 491
466 // Jump <imm8> 492 // Jump <imm8>
467 // 493 //
468 // Jump by number of bytes represented by an immediate operand. 494 // Jump by number of bytes represented by the immediate operand |imm8|.
469 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) { 495 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) {
470 Node* relative_jump = __ BytecodeOperandImm8(0); 496 Node* relative_jump = __ BytecodeOperandImm8(0);
471 __ Jump(relative_jump); 497 __ Jump(relative_jump);
472 } 498 }
473 499
474 500
475 // JumpConstant <idx> 501 // JumpConstant <idx>
476 // 502 //
477 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool. 503 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool.
478 void Interpreter::DoJumpConstant(compiler::InterpreterAssembler* assembler) { 504 void Interpreter::DoJumpConstant(compiler::InterpreterAssembler* assembler) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 Node* index = __ BytecodeOperandIdx8(0); 558 Node* index = __ BytecodeOperandIdx8(0);
533 Node* constant = __ LoadConstantPoolEntry(index); 559 Node* constant = __ LoadConstantPoolEntry(index);
534 Node* relative_jump = __ SmiUntag(constant); 560 Node* relative_jump = __ SmiUntag(constant);
535 Node* false_value = __ BooleanConstant(false); 561 Node* false_value = __ BooleanConstant(false);
536 __ JumpIfWordEqual(accumulator, false_value, relative_jump); 562 __ JumpIfWordEqual(accumulator, false_value, relative_jump);
537 } 563 }
538 564
539 565
540 // Return 566 // Return
541 // 567 //
542 // Return the value in register 0. 568 // Return the value in the accumulator.
543 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { 569 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) {
544 __ Return(); 570 __ Return();
545 } 571 }
546 572
547 573
548 } // namespace interpreter 574 } // namespace interpreter
549 } // namespace internal 575 } // namespace internal
550 } // namespace v8 576 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698