OLD | NEW |
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // operations, instead of calling builtins directly. | 287 // operations, instead of calling builtins directly. |
288 Node* reg_index = __ BytecodeOperandReg(0); | 288 Node* reg_index = __ BytecodeOperandReg(0); |
289 Node* lhs = __ LoadRegister(reg_index); | 289 Node* lhs = __ LoadRegister(reg_index); |
290 Node* rhs = __ GetAccumulator(); | 290 Node* rhs = __ GetAccumulator(); |
291 Node* result = __ CallRuntime(function_id, lhs, rhs); | 291 Node* result = __ CallRuntime(function_id, lhs, rhs); |
292 __ SetAccumulator(result); | 292 __ SetAccumulator(result); |
293 __ Dispatch(); | 293 __ Dispatch(); |
294 } | 294 } |
295 | 295 |
296 | 296 |
297 void Interpreter::DoCompareOp(Token::Value op, | |
298 compiler::InterpreterAssembler* assembler) { | |
299 // TODO(oth): placeholder until compare path fixed. | |
300 // The accumulator should be set to true on success (or false otherwise) | |
301 // by the comparisons so it can be used for conditional jumps. | |
302 DoLdaTrue(assembler); | |
303 } | |
304 | |
305 | |
306 // Add <src> | 297 // Add <src> |
307 // | 298 // |
308 // Add register <src> to accumulator. | 299 // Add register <src> to accumulator. |
309 void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) { | 300 void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) { |
310 DoBinaryOp(Runtime::kAdd, assembler); | 301 DoBinaryOp(Runtime::kAdd, assembler); |
311 } | 302 } |
312 | 303 |
313 | 304 |
314 // Sub <src> | 305 // Sub <src> |
315 // | 306 // |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 Node* result = __ CallJS(function, first_arg, args_count); | 347 Node* result = __ CallJS(function, first_arg, args_count); |
357 __ SetAccumulator(result); | 348 __ SetAccumulator(result); |
358 __ Dispatch(); | 349 __ Dispatch(); |
359 } | 350 } |
360 | 351 |
361 | 352 |
362 // TestEqual <src> | 353 // TestEqual <src> |
363 // | 354 // |
364 // Test if the value in the <src> register equals the accumulator. | 355 // Test if the value in the <src> register equals the accumulator. |
365 void Interpreter::DoTestEqual(compiler::InterpreterAssembler* assembler) { | 356 void Interpreter::DoTestEqual(compiler::InterpreterAssembler* assembler) { |
366 DoCompareOp(Token::Value::EQ, assembler); | 357 DoBinaryOp(Runtime::kInterpreterEquals, assembler); |
367 } | 358 } |
368 | 359 |
369 | 360 |
370 // TestNotEqual <src> | 361 // TestNotEqual <src> |
371 // | 362 // |
372 // Test if the value in the <src> register is not equal to the accumulator. | 363 // Test if the value in the <src> register is not equal to the accumulator. |
373 void Interpreter::DoTestNotEqual(compiler::InterpreterAssembler* assembler) { | 364 void Interpreter::DoTestNotEqual(compiler::InterpreterAssembler* assembler) { |
374 DoCompareOp(Token::Value::NE, assembler); | 365 DoBinaryOp(Runtime::kInterpreterNotEquals, assembler); |
375 } | 366 } |
376 | 367 |
377 | 368 |
378 // TestEqualStrict <src> | 369 // TestEqualStrict <src> |
379 // | 370 // |
380 // Test if the value in the <src> register is strictly equal to the accumulator. | 371 // Test if the value in the <src> register is strictly equal to the accumulator. |
381 void Interpreter::DoTestEqualStrict(compiler::InterpreterAssembler* assembler) { | 372 void Interpreter::DoTestEqualStrict(compiler::InterpreterAssembler* assembler) { |
382 DoCompareOp(Token::Value::EQ_STRICT, assembler); | 373 DoBinaryOp(Runtime::kInterpreterStrictEquals, assembler); |
383 } | 374 } |
384 | 375 |
385 | 376 |
386 // TestNotEqualStrict <src> | 377 // TestNotEqualStrict <src> |
387 // | 378 // |
388 // Test if the value in the <src> register is not strictly equal to the | 379 // Test if the value in the <src> register is not strictly equal to the |
389 // accumulator. | 380 // accumulator. |
390 void Interpreter::DoTestNotEqualStrict( | 381 void Interpreter::DoTestNotEqualStrict( |
391 compiler::InterpreterAssembler* assembler) { | 382 compiler::InterpreterAssembler* assembler) { |
392 DoCompareOp(Token::Value::NE_STRICT, assembler); | 383 DoBinaryOp(Runtime::kInterpreterStrictNotEquals, assembler); |
393 } | 384 } |
394 | 385 |
395 | 386 |
396 // TestLessThan <src> | 387 // TestLessThan <src> |
397 // | 388 // |
398 // Test if the value in the <src> register is less than the accumulator. | 389 // Test if the value in the <src> register is less than the accumulator. |
399 void Interpreter::DoTestLessThan(compiler::InterpreterAssembler* assembler) { | 390 void Interpreter::DoTestLessThan(compiler::InterpreterAssembler* assembler) { |
400 DoCompareOp(Token::Value::LT, assembler); | 391 DoBinaryOp(Runtime::kInterpreterLessThan, assembler); |
401 } | 392 } |
402 | 393 |
403 | 394 |
404 // TestGreaterThan <src> | 395 // TestGreaterThan <src> |
405 // | 396 // |
406 // Test if the value in the <src> register is greater than the accumulator. | 397 // Test if the value in the <src> register is greater than the accumulator. |
407 void Interpreter::DoTestGreaterThan(compiler::InterpreterAssembler* assembler) { | 398 void Interpreter::DoTestGreaterThan(compiler::InterpreterAssembler* assembler) { |
408 DoCompareOp(Token::Value::GT, assembler); | 399 DoBinaryOp(Runtime::kInterpreterGreaterThan, assembler); |
409 } | 400 } |
410 | 401 |
411 | 402 |
412 // TestLessThanEqual <src> | 403 // TestLessThanEqual <src> |
413 // | 404 // |
414 // Test if the value in the <src> register is less than or equal to the | 405 // Test if the value in the <src> register is less than or equal to the |
415 // accumulator. | 406 // accumulator. |
416 void Interpreter::DoTestLessThanEqual( | 407 void Interpreter::DoTestLessThanEqual( |
417 compiler::InterpreterAssembler* assembler) { | 408 compiler::InterpreterAssembler* assembler) { |
418 DoCompareOp(Token::Value::LTE, assembler); | 409 DoBinaryOp(Runtime::kInterpreterLessThanEqual, assembler); |
419 } | 410 } |
420 | 411 |
421 | 412 |
422 // TestGreaterThanEqual <src> | 413 // TestGreaterThanEqual <src> |
423 // | 414 // |
424 // Test if the value in the <src> register is greater than or equal to the | 415 // Test if the value in the <src> register is greater than or equal to the |
425 // accumulator. | 416 // accumulator. |
426 void Interpreter::DoTestGreaterThanEqual( | 417 void Interpreter::DoTestGreaterThanEqual( |
427 compiler::InterpreterAssembler* assembler) { | 418 compiler::InterpreterAssembler* assembler) { |
428 DoCompareOp(Token::Value::GTE, assembler); | 419 DoBinaryOp(Runtime::kInterpreterGreaterThanEqual, assembler); |
429 } | 420 } |
430 | 421 |
431 | 422 |
432 // TestIn <src> | 423 // TestIn <src> |
433 // | 424 // |
434 // Test if the value in the <src> register is in the collection referenced | 425 // Test if the object referenced by the register operand is a property of the |
435 // by the accumulator. | 426 // object referenced by the accumulator. |
436 void Interpreter::DoTestIn(compiler::InterpreterAssembler* assembler) { | 427 void Interpreter::DoTestIn(compiler::InterpreterAssembler* assembler) { |
437 DoCompareOp(Token::Value::IN, assembler); | 428 DoBinaryOp(Runtime::kHasProperty, assembler); |
438 } | 429 } |
439 | 430 |
440 | 431 |
441 // TestInstanceOf <src> | 432 // TestInstanceOf <src> |
442 // | 433 // |
443 // Test if the object referenced by the <src> register is an an instance of type | 434 // Test if the object referenced by the <src> register is an an instance of type |
444 // referenced by the accumulator. | 435 // referenced by the accumulator. |
445 void Interpreter::DoTestInstanceOf(compiler::InterpreterAssembler* assembler) { | 436 void Interpreter::DoTestInstanceOf(compiler::InterpreterAssembler* assembler) { |
446 DoCompareOp(Token::Value::INSTANCEOF, assembler); | 437 DoBinaryOp(Runtime::kInstanceOf, assembler); |
447 } | 438 } |
448 | 439 |
449 | 440 |
450 // ToBoolean | 441 // ToBoolean |
451 // | 442 // |
452 // Cast the object referenced by the accumulator to a boolean. | 443 // Cast the object referenced by the accumulator to a boolean. |
453 void Interpreter::DoToBoolean(compiler::InterpreterAssembler* assembler) { | 444 void Interpreter::DoToBoolean(compiler::InterpreterAssembler* assembler) { |
454 // TODO(oth): The next CL for test operations has interpreter specific | 445 // TODO(oth): The next CL for test operations has interpreter specific |
455 // runtime calls. This looks like another candidate. | 446 // runtime calls. This looks like another candidate. |
456 __ Dispatch(); | 447 __ Dispatch(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 // | 526 // |
536 // Return the value in register 0. | 527 // Return the value in register 0. |
537 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 528 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
538 __ Return(); | 529 __ Return(); |
539 } | 530 } |
540 | 531 |
541 | 532 |
542 } // namespace interpreter | 533 } // namespace interpreter |
543 } // namespace internal | 534 } // namespace internal |
544 } // namespace v8 | 535 } // namespace v8 |
OLD | NEW |