Chromium Code Reviews| 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-assembler.h" | 5 #include "src/interpreter/interpreter-assembler.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/frames.h" | 10 #include "src/frames.h" |
| 11 #include "src/interface-descriptors.h" | 11 #include "src/interface-descriptors.h" |
| 12 #include "src/interpreter/bytecodes.h" | 12 #include "src/interpreter/bytecodes.h" |
| 13 #include "src/interpreter/interpreter.h" | |
| 13 #include "src/machine-type.h" | 14 #include "src/machine-type.h" |
| 14 #include "src/macro-assembler.h" | 15 #include "src/macro-assembler.h" |
| 15 #include "src/zone.h" | 16 #include "src/zone.h" |
| 16 | 17 |
| 17 namespace v8 { | 18 namespace v8 { |
| 18 namespace internal { | 19 namespace internal { |
| 19 namespace interpreter { | 20 namespace interpreter { |
| 20 | 21 |
| 21 using compiler::Node; | 22 using compiler::Node; |
| 22 | 23 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 Int32Mul(function_id, Int32Constant(sizeof(Runtime::Function))); | 365 Int32Mul(function_id, Int32Constant(sizeof(Runtime::Function))); |
| 365 Node* function = IntPtrAdd(function_table, function_offset); | 366 Node* function = IntPtrAdd(function_table, function_offset); |
| 366 Node* function_entry = | 367 Node* function_entry = |
| 367 Load(MachineType::Pointer(), function, | 368 Load(MachineType::Pointer(), function, |
| 368 Int32Constant(offsetof(Runtime::Function, entry))); | 369 Int32Constant(offsetof(Runtime::Function, entry))); |
| 369 | 370 |
| 370 return CallStub(callable.descriptor(), code_target, context, arg_count, | 371 return CallStub(callable.descriptor(), code_target, context, arg_count, |
| 371 first_arg, function_entry, result_size); | 372 first_arg, function_entry, result_size); |
| 372 } | 373 } |
| 373 | 374 |
| 375 void InterpreterAssembler::UpdateProfilingCount(Node* weight) { | |
| 376 CodeStubAssembler::Label ok(this); | |
| 377 CodeStubAssembler::Label interrupt_check(this); | |
| 378 CodeStubAssembler::Label end(this); | |
| 379 Node* counter_offset = | |
| 380 IntPtrConstant(BytecodeArray::kProfilingCountOffset - kHeapObjectTag); | |
| 381 | |
| 382 // Update counter by |weight| and check if it reaches zero. | |
| 383 Node* old_count = | |
| 384 Load(MachineType::Int32(), BytecodeArrayTaggedPointer(), counter_offset); | |
| 385 Node* new_count = Int32Add(old_count, weight); | |
| 386 Node* condition = Int32GreaterThanOrEqual(new_count, Int32Constant(0)); | |
| 387 Branch(condition, &ok, &interrupt_check); | |
| 388 | |
| 389 // Perform interrupt and reset counter. | |
| 390 Bind(&interrupt_check); | |
| 391 CallRuntime(Runtime::kInterrupt, GetContext()); | |
| 392 StoreNoWriteBarrier(MachineRepresentation::kWord32, | |
| 393 BytecodeArrayTaggedPointer(), counter_offset, | |
| 394 Int32Constant(Interpreter::InterruptBudget())); | |
| 395 Goto(&end); | |
| 396 | |
| 397 // Update counter. | |
| 398 Bind(&ok); | |
| 399 StoreNoWriteBarrier(MachineRepresentation::kWord32, | |
| 400 BytecodeArrayTaggedPointer(), counter_offset, new_count); | |
| 401 Goto(&end); | |
| 402 Bind(&end); | |
| 403 } | |
| 404 | |
| 374 Node* InterpreterAssembler::Advance(int delta) { | 405 Node* InterpreterAssembler::Advance(int delta) { |
| 375 return IntPtrAdd(BytecodeOffset(), Int32Constant(delta)); | 406 return IntPtrAdd(BytecodeOffset(), Int32Constant(delta)); |
| 376 } | 407 } |
| 377 | 408 |
| 378 Node* InterpreterAssembler::Advance(Node* delta) { | 409 Node* InterpreterAssembler::Advance(Node* delta) { |
| 379 return IntPtrAdd(BytecodeOffset(), delta); | 410 return IntPtrAdd(BytecodeOffset(), delta); |
| 380 } | 411 } |
| 381 | 412 |
| 382 void InterpreterAssembler::Jump(Node* delta) { DispatchTo(Advance(delta)); } | 413 void InterpreterAssembler::Jump(Node* delta) { |
| 414 UpdateProfilingCount(delta); | |
| 415 DispatchTo(Advance(delta)); | |
| 416 } | |
| 383 | 417 |
| 384 void InterpreterAssembler::JumpConditional(Node* condition, Node* delta) { | 418 void InterpreterAssembler::JumpConditional(Node* condition, Node* delta) { |
| 385 CodeStubAssembler::Label match(this); | 419 CodeStubAssembler::Label match(this); |
| 386 CodeStubAssembler::Label no_match(this); | 420 CodeStubAssembler::Label no_match(this); |
| 387 | 421 |
| 388 Branch(condition, &match, &no_match); | 422 Branch(condition, &match, &no_match); |
| 389 Bind(&match); | 423 Bind(&match); |
| 390 DispatchTo(Advance(delta)); | 424 Jump(delta); |
| 391 Bind(&no_match); | 425 Bind(&no_match); |
| 392 Dispatch(); | 426 Dispatch(); |
| 393 } | 427 } |
| 394 | 428 |
| 395 void InterpreterAssembler::JumpIfWordEqual(Node* lhs, Node* rhs, Node* delta) { | 429 void InterpreterAssembler::JumpIfWordEqual(Node* lhs, Node* rhs, Node* delta) { |
| 396 JumpConditional(WordEqual(lhs, rhs), delta); | 430 JumpConditional(WordEqual(lhs, rhs), delta); |
| 397 } | 431 } |
| 398 | 432 |
| 399 void InterpreterAssembler::JumpIfWordNotEqual(Node* lhs, Node* rhs, | 433 void InterpreterAssembler::JumpIfWordNotEqual(Node* lhs, Node* rhs, |
| 400 Node* delta) { | 434 Node* delta) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 422 Node* args[] = {GetAccumulator(), RegisterFileRawPointer(), | 456 Node* args[] = {GetAccumulator(), RegisterFileRawPointer(), |
| 423 new_bytecode_offset, BytecodeArrayTaggedPointer(), | 457 new_bytecode_offset, BytecodeArrayTaggedPointer(), |
| 424 DispatchTableRawPointer(), GetContext()}; | 458 DispatchTableRawPointer(), GetContext()}; |
| 425 TailCall(descriptor, target_code_object, args, 0); | 459 TailCall(descriptor, target_code_object, args, 0); |
| 426 } | 460 } |
| 427 | 461 |
| 428 void InterpreterAssembler::InterpreterReturn() { | 462 void InterpreterAssembler::InterpreterReturn() { |
| 429 if (FLAG_trace_ignition) { | 463 if (FLAG_trace_ignition) { |
| 430 TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); | 464 TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); |
| 431 } | 465 } |
| 466 | |
| 467 // TODO(rmcilroy): Deal with self optimization of primitive functions. | |
|
Michael Starzinger
2016/02/18 17:55:26
Just for posterity: Unless we have data supporting
rmcilroy
2016/02/19 12:32:32
Ack. Updated comment.
| |
| 468 // Update profiling count by -BytecodeOffset to simulate backedge to start of | |
| 469 // function. | |
| 470 Node* profiling_weight = | |
| 471 Int32Sub(Int32Constant(kHeapObjectTag + BytecodeArray::kHeaderSize), | |
| 472 BytecodeOffset()); | |
| 473 UpdateProfilingCount(profiling_weight); | |
| 474 | |
| 432 InterpreterDispatchDescriptor descriptor(isolate()); | 475 InterpreterDispatchDescriptor descriptor(isolate()); |
| 433 Node* exit_trampoline_code_object = | 476 Node* exit_trampoline_code_object = |
| 434 HeapConstant(isolate()->builtins()->InterpreterExitTrampoline()); | 477 HeapConstant(isolate()->builtins()->InterpreterExitTrampoline()); |
| 435 Node* args[] = {GetAccumulator(), RegisterFileRawPointer(), | 478 Node* args[] = {GetAccumulator(), RegisterFileRawPointer(), |
| 436 BytecodeOffset(), BytecodeArrayTaggedPointer(), | 479 BytecodeOffset(), BytecodeArrayTaggedPointer(), |
| 437 DispatchTableRawPointer(), GetContext()}; | 480 DispatchTableRawPointer(), GetContext()}; |
| 438 TailCall(descriptor, exit_trampoline_code_object, args, 0); | 481 TailCall(descriptor, exit_trampoline_code_object, args, 0); |
| 439 } | 482 } |
| 440 | 483 |
| 441 void InterpreterAssembler::StackCheck() { | 484 void InterpreterAssembler::StackCheck() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 | 535 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 |
| 493 return true; | 536 return true; |
| 494 #else | 537 #else |
| 495 #error "Unknown Architecture" | 538 #error "Unknown Architecture" |
| 496 #endif | 539 #endif |
| 497 } | 540 } |
| 498 | 541 |
| 499 } // namespace interpreter | 542 } // namespace interpreter |
| 500 } // namespace internal | 543 } // namespace internal |
| 501 } // namespace v8 | 544 } // namespace v8 |
| OLD | NEW |