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

Side by Side Diff: src/compiler/interpreter-assembler.cc

Issue 1379793004: [Interpreter] Add support for new local function context creation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_decl
Patch Set: Fix interpreter-assembler-unittest 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/compiler/interpreter-assembler.h ('k') | src/compiler/linkage.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/compiler/interpreter-assembler.h" 5 #include "src/compiler/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/compiler/graph.h" 10 #include "src/compiler/graph.h"
(...skipping 17 matching lines...) Expand all
28 InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone, 28 InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone,
29 interpreter::Bytecode bytecode) 29 interpreter::Bytecode bytecode)
30 : bytecode_(bytecode), 30 : bytecode_(bytecode),
31 raw_assembler_(new RawMachineAssembler( 31 raw_assembler_(new RawMachineAssembler(
32 isolate, new (zone) Graph(zone), 32 isolate, new (zone) Graph(zone),
33 Linkage::GetInterpreterDispatchDescriptor(zone), kMachPtr, 33 Linkage::GetInterpreterDispatchDescriptor(zone), kMachPtr,
34 InstructionSelector::SupportedMachineOperatorFlags())), 34 InstructionSelector::SupportedMachineOperatorFlags())),
35 end_nodes_(zone), 35 end_nodes_(zone),
36 accumulator_( 36 accumulator_(
37 raw_assembler_->Parameter(Linkage::kInterpreterAccumulatorParameter)), 37 raw_assembler_->Parameter(Linkage::kInterpreterAccumulatorParameter)),
38 context_(
39 raw_assembler_->Parameter(Linkage::kInterpreterContextParameter)),
38 code_generated_(false) {} 40 code_generated_(false) {}
39 41
40 42
41 InterpreterAssembler::~InterpreterAssembler() {} 43 InterpreterAssembler::~InterpreterAssembler() {}
42 44
43 45
44 Handle<Code> InterpreterAssembler::GenerateCode() { 46 Handle<Code> InterpreterAssembler::GenerateCode() {
45 DCHECK(!code_generated_); 47 DCHECK(!code_generated_);
46 48
47 End(); 49 End();
(...skipping 11 matching lines...) Expand all
59 code->Disassemble(bytecode_name, os); 61 code->Disassemble(bytecode_name, os);
60 os << std::flush; 62 os << std::flush;
61 } 63 }
62 #endif 64 #endif
63 65
64 code_generated_ = true; 66 code_generated_ = true;
65 return code; 67 return code;
66 } 68 }
67 69
68 70
69 Node* InterpreterAssembler::GetAccumulator() { 71 Node* InterpreterAssembler::GetAccumulator() { return accumulator_; }
70 return accumulator_;
71 }
72 72
73 73
74 void InterpreterAssembler::SetAccumulator(Node* value) { 74 void InterpreterAssembler::SetAccumulator(Node* value) { accumulator_ = value; }
75 accumulator_ = value;
76 }
77 75
78 76
79 Node* InterpreterAssembler::ContextTaggedPointer() { 77 Node* InterpreterAssembler::GetContext() { return context_; }
80 return raw_assembler_->Parameter(Linkage::kInterpreterContextParameter); 78
81 } 79
80 void InterpreterAssembler::SetContext(Node* value) { context_ = value; }
82 81
83 82
84 Node* InterpreterAssembler::RegisterFileRawPointer() { 83 Node* InterpreterAssembler::RegisterFileRawPointer() {
85 return raw_assembler_->Parameter(Linkage::kInterpreterRegisterFileParameter); 84 return raw_assembler_->Parameter(Linkage::kInterpreterRegisterFileParameter);
86 } 85 }
87 86
88 87
89 Node* InterpreterAssembler::BytecodeArrayTaggedPointer() { 88 Node* InterpreterAssembler::BytecodeArrayTaggedPointer() {
90 return raw_assembler_->Parameter(Linkage::kInterpreterBytecodeArrayParameter); 89 return raw_assembler_->Parameter(Linkage::kInterpreterBytecodeArrayParameter);
91 } 90 }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 Callable callable = CodeFactory::InterpreterPushArgsAndCall(isolate()); 331 Callable callable = CodeFactory::InterpreterPushArgsAndCall(isolate());
333 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( 332 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
334 isolate(), zone(), callable.descriptor(), 0, CallDescriptor::kNoFlags); 333 isolate(), zone(), callable.descriptor(), 0, CallDescriptor::kNoFlags);
335 334
336 Node* code_target = HeapConstant(callable.code()); 335 Node* code_target = HeapConstant(callable.code());
337 336
338 Node** args = zone()->NewArray<Node*>(4); 337 Node** args = zone()->NewArray<Node*>(4);
339 args[0] = arg_count; 338 args[0] = arg_count;
340 args[1] = first_arg; 339 args[1] = first_arg;
341 args[2] = function; 340 args[2] = function;
342 args[3] = ContextTaggedPointer(); 341 args[3] = GetContext();
343 342
344 return CallN(descriptor, code_target, args); 343 return CallN(descriptor, code_target, args);
345 } 344 }
346 345
347 346
348 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor, 347 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor,
349 Node* target, Node** args) { 348 Node* target, Node** args) {
350 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 349 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
351 isolate(), zone(), descriptor, 0, CallDescriptor::kNoFlags); 350 isolate(), zone(), descriptor, 0, CallDescriptor::kNoFlags);
352 return CallN(call_descriptor, target, args); 351 return CallN(call_descriptor, target, args);
353 } 352 }
354 353
355 354
356 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor, 355 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor,
357 Node* target, Node* arg1, Node* arg2, 356 Node* target, Node* arg1, Node* arg2,
358 Node* arg3, Node* arg4) { 357 Node* arg3, Node* arg4) {
359 Node** args = zone()->NewArray<Node*>(5); 358 Node** args = zone()->NewArray<Node*>(5);
360 args[0] = arg1; 359 args[0] = arg1;
361 args[1] = arg2; 360 args[1] = arg2;
362 args[2] = arg3; 361 args[2] = arg3;
363 args[3] = arg4; 362 args[3] = arg4;
364 args[4] = ContextTaggedPointer(); 363 args[4] = GetContext();
365 return CallIC(descriptor, target, args); 364 return CallIC(descriptor, target, args);
366 } 365 }
367 366
368 367
369 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor, 368 Node* InterpreterAssembler::CallIC(CallInterfaceDescriptor descriptor,
370 Node* target, Node* arg1, Node* arg2, 369 Node* target, Node* arg1, Node* arg2,
371 Node* arg3, Node* arg4, Node* arg5) { 370 Node* arg3, Node* arg4, Node* arg5) {
372 Node** args = zone()->NewArray<Node*>(6); 371 Node** args = zone()->NewArray<Node*>(6);
373 args[0] = arg1; 372 args[0] = arg1;
374 args[1] = arg2; 373 args[1] = arg2;
375 args[2] = arg3; 374 args[2] = arg3;
376 args[3] = arg4; 375 args[3] = arg4;
377 args[4] = arg5; 376 args[4] = arg5;
378 args[5] = ContextTaggedPointer(); 377 args[5] = GetContext();
379 return CallIC(descriptor, target, args); 378 return CallIC(descriptor, target, args);
380 } 379 }
381 380
382 381
383 Node* InterpreterAssembler::CallRuntime(Node* function_id, Node* first_arg, 382 Node* InterpreterAssembler::CallRuntime(Node* function_id, Node* first_arg,
384 Node* arg_count) { 383 Node* arg_count) {
385 Callable callable = CodeFactory::InterpreterCEntry(isolate()); 384 Callable callable = CodeFactory::InterpreterCEntry(isolate());
386 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor( 385 CallDescriptor* descriptor = Linkage::GetStubCallDescriptor(
387 isolate(), zone(), callable.descriptor(), 0, CallDescriptor::kNoFlags); 386 isolate(), zone(), callable.descriptor(), 0, CallDescriptor::kNoFlags);
388 387
389 Node* code_target = HeapConstant(callable.code()); 388 Node* code_target = HeapConstant(callable.code());
390 389
391 // Get the function entry from the function id. 390 // Get the function entry from the function id.
392 Node* function_table = raw_assembler_->ExternalConstant( 391 Node* function_table = raw_assembler_->ExternalConstant(
393 ExternalReference::runtime_function_table_address(isolate())); 392 ExternalReference::runtime_function_table_address(isolate()));
394 Node* function_offset = raw_assembler_->Int32Mul( 393 Node* function_offset = raw_assembler_->Int32Mul(
395 function_id, Int32Constant(sizeof(Runtime::Function))); 394 function_id, Int32Constant(sizeof(Runtime::Function)));
396 Node* function = IntPtrAdd(function_table, function_offset); 395 Node* function = IntPtrAdd(function_table, function_offset);
397 Node* function_entry = raw_assembler_->Load( 396 Node* function_entry = raw_assembler_->Load(
398 kMachPtr, function, Int32Constant(offsetof(Runtime::Function, entry))); 397 kMachPtr, function, Int32Constant(offsetof(Runtime::Function, entry)));
399 398
400 Node** args = zone()->NewArray<Node*>(4); 399 Node** args = zone()->NewArray<Node*>(4);
401 args[0] = arg_count; 400 args[0] = arg_count;
402 args[1] = first_arg; 401 args[1] = first_arg;
403 args[2] = function_entry; 402 args[2] = function_entry;
404 args[3] = ContextTaggedPointer(); 403 args[3] = GetContext();
405 404
406 return CallN(descriptor, code_target, args); 405 return CallN(descriptor, code_target, args);
407 } 406 }
408 407
409 408
410 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id, 409 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id,
411 Node* arg1) { 410 Node* arg1) {
412 return raw_assembler_->CallRuntime1(function_id, arg1, 411 return raw_assembler_->CallRuntime1(function_id, arg1, GetContext());
413 ContextTaggedPointer());
414 } 412 }
415 413
416 414
417 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id, 415 Node* InterpreterAssembler::CallRuntime(Runtime::FunctionId function_id,
418 Node* arg1, Node* arg2) { 416 Node* arg1, Node* arg2) {
419 return raw_assembler_->CallRuntime2(function_id, arg1, arg2, 417 return raw_assembler_->CallRuntime2(function_id, arg1, arg2, GetContext());
420 ContextTaggedPointer());
421 } 418 }
422 419
423 420
424 void InterpreterAssembler::Return() { 421 void InterpreterAssembler::Return() {
425 Node* exit_trampoline_code_object = 422 Node* exit_trampoline_code_object =
426 HeapConstant(isolate()->builtins()->InterpreterExitTrampoline()); 423 HeapConstant(isolate()->builtins()->InterpreterExitTrampoline());
427 // If the order of the parameters you need to change the call signature below. 424 // If the order of the parameters you need to change the call signature below.
428 STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter); 425 STATIC_ASSERT(0 == Linkage::kInterpreterAccumulatorParameter);
429 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter); 426 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter);
430 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter); 427 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter);
431 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter); 428 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter);
432 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter); 429 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter);
433 STATIC_ASSERT(5 == Linkage::kInterpreterContextParameter); 430 STATIC_ASSERT(5 == Linkage::kInterpreterContextParameter);
434 Node* args[] = { GetAccumulator(), 431 Node* args[] = { GetAccumulator(),
435 RegisterFileRawPointer(), 432 RegisterFileRawPointer(),
436 BytecodeOffset(), 433 BytecodeOffset(),
437 BytecodeArrayTaggedPointer(), 434 BytecodeArrayTaggedPointer(),
438 DispatchTableRawPointer(), 435 DispatchTableRawPointer(),
439 ContextTaggedPointer() }; 436 GetContext() };
440 Node* tail_call = raw_assembler_->TailCallN( 437 Node* tail_call = raw_assembler_->TailCallN(
441 call_descriptor(), exit_trampoline_code_object, args); 438 call_descriptor(), exit_trampoline_code_object, args);
442 // This should always be the end node. 439 // This should always be the end node.
443 AddEndInput(tail_call); 440 AddEndInput(tail_call);
444 } 441 }
445 442
446 443
447 Node* InterpreterAssembler::Advance(int delta) { 444 Node* InterpreterAssembler::Advance(int delta) {
448 return IntPtrAdd(BytecodeOffset(), Int32Constant(delta)); 445 return IntPtrAdd(BytecodeOffset(), Int32Constant(delta));
449 } 446 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter); 486 STATIC_ASSERT(1 == Linkage::kInterpreterRegisterFileParameter);
490 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter); 487 STATIC_ASSERT(2 == Linkage::kInterpreterBytecodeOffsetParameter);
491 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter); 488 STATIC_ASSERT(3 == Linkage::kInterpreterBytecodeArrayParameter);
492 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter); 489 STATIC_ASSERT(4 == Linkage::kInterpreterDispatchTableParameter);
493 STATIC_ASSERT(5 == Linkage::kInterpreterContextParameter); 490 STATIC_ASSERT(5 == Linkage::kInterpreterContextParameter);
494 Node* args[] = { GetAccumulator(), 491 Node* args[] = { GetAccumulator(),
495 RegisterFileRawPointer(), 492 RegisterFileRawPointer(),
496 new_bytecode_offset, 493 new_bytecode_offset,
497 BytecodeArrayTaggedPointer(), 494 BytecodeArrayTaggedPointer(),
498 DispatchTableRawPointer(), 495 DispatchTableRawPointer(),
499 ContextTaggedPointer() }; 496 GetContext() };
500 Node* tail_call = 497 Node* tail_call =
501 raw_assembler_->TailCallN(call_descriptor(), target_code_object, args); 498 raw_assembler_->TailCallN(call_descriptor(), target_code_object, args);
502 // This should always be the end node. 499 // This should always be the end node.
503 AddEndInput(tail_call); 500 AddEndInput(tail_call);
504 } 501 }
505 502
506 503
507 void InterpreterAssembler::AbortIfWordNotEqual(Node* lhs, Node* rhs, 504 void InterpreterAssembler::AbortIfWordNotEqual(Node* lhs, Node* rhs,
508 BailoutReason bailout_reason) { 505 BailoutReason bailout_reason) {
509 RawMachineAssembler::Label match, no_match; 506 RawMachineAssembler::Label match, no_match;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 return raw_assembler_->schedule(); 559 return raw_assembler_->schedule();
563 } 560 }
564 561
565 562
566 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); } 563 Zone* InterpreterAssembler::zone() { return raw_assembler_->zone(); }
567 564
568 565
569 } // namespace compiler 566 } // namespace compiler
570 } // namespace internal 567 } // namespace internal
571 } // namespace v8 568 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/interpreter-assembler.h ('k') | src/compiler/linkage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698