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/compiler/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
8 #include "src/compiler/operator-properties.h" | 8 #include "src/compiler/operator-properties.h" |
9 #include "src/interpreter/bytecode-array-iterator.h" | 9 #include "src/interpreter/bytecode-array-iterator.h" |
10 | 10 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 } | 155 } |
156 | 156 |
157 | 157 |
158 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { | 158 VectorSlotPair BytecodeGraphBuilder::CreateVectorSlotPair(int slot_id) { |
159 Handle<TypeFeedbackVector> feedback_vector = info()->feedback_vector(); | 159 Handle<TypeFeedbackVector> feedback_vector = info()->feedback_vector(); |
160 FeedbackVectorSlot slot = feedback_vector->ToSlot(slot_id); | 160 FeedbackVectorSlot slot = feedback_vector->ToSlot(slot_id); |
161 return VectorSlotPair(feedback_vector, slot); | 161 return VectorSlotPair(feedback_vector, slot); |
162 } | 162 } |
163 | 163 |
164 | 164 |
165 // TODO(mythria): Replace this function with one which adds real frame state. | |
166 // Also add before and after frame states and checkpointing if required. | |
165 void BytecodeGraphBuilder::AddEmptyFrameStateInputs(Node* node) { | 167 void BytecodeGraphBuilder::AddEmptyFrameStateInputs(Node* node) { |
166 int frame_state_count = | 168 int frame_state_count = |
167 OperatorProperties::GetFrameStateInputCount(node->op()); | 169 OperatorProperties::GetFrameStateInputCount(node->op()); |
168 for (int i = 0; i < frame_state_count; i++) { | 170 for (int i = 0; i < frame_state_count; i++) { |
169 NodeProperties::ReplaceFrameStateInput(node, i, | 171 NodeProperties::ReplaceFrameStateInput(node, i, |
170 jsgraph()->EmptyFrameState()); | 172 jsgraph()->EmptyFrameState()); |
171 } | 173 } |
172 } | 174 } |
173 | 175 |
174 | 176 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 | 392 |
391 void BytecodeGraphBuilder::BuildNamedLoad( | 393 void BytecodeGraphBuilder::BuildNamedLoad( |
392 const interpreter::BytecodeArrayIterator& iterator) { | 394 const interpreter::BytecodeArrayIterator& iterator) { |
393 Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 395 Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); |
394 Handle<Name> name = | 396 Handle<Name> name = |
395 Handle<Name>::cast(iterator.GetConstantForIndexOperand(1)); | 397 Handle<Name>::cast(iterator.GetConstantForIndexOperand(1)); |
396 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(2)); | 398 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(2)); |
397 | 399 |
398 const Operator* op = javascript()->LoadNamed(language_mode(), name, feedback); | 400 const Operator* op = javascript()->LoadNamed(language_mode(), name, feedback); |
399 Node* node = NewNode(op, object, BuildLoadFeedbackVector()); | 401 Node* node = NewNode(op, object, BuildLoadFeedbackVector()); |
400 // TODO(mythria): Replace with real frame state. Also add before and after | |
401 // frame states if required. | |
402 AddEmptyFrameStateInputs(node); | 402 AddEmptyFrameStateInputs(node); |
403 environment()->BindAccumulator(node); | 403 environment()->BindAccumulator(node); |
404 } | 404 } |
405 | 405 |
406 | 406 |
407 void BytecodeGraphBuilder::VisitLoadICSloppy( | 407 void BytecodeGraphBuilder::VisitLoadICSloppy( |
408 const interpreter::BytecodeArrayIterator& iterator) { | 408 const interpreter::BytecodeArrayIterator& iterator) { |
409 DCHECK(is_sloppy(language_mode())); | 409 DCHECK(is_sloppy(language_mode())); |
410 BuildNamedLoad(iterator); | 410 BuildNamedLoad(iterator); |
411 } | 411 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 UNIMPLEMENTED(); | 545 UNIMPLEMENTED(); |
546 } | 546 } |
547 | 547 |
548 | 548 |
549 void BytecodeGraphBuilder::VisitCreateObjectLiteral( | 549 void BytecodeGraphBuilder::VisitCreateObjectLiteral( |
550 const interpreter::BytecodeArrayIterator& iterator) { | 550 const interpreter::BytecodeArrayIterator& iterator) { |
551 UNIMPLEMENTED(); | 551 UNIMPLEMENTED(); |
552 } | 552 } |
553 | 553 |
554 | 554 |
555 Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op, | |
556 interpreter::Register callee, | |
557 interpreter::Register receiver, | |
558 size_t arity) { | |
559 Node** all = info()->zone()->NewArray<Node*>(arity); | |
560 all[0] = environment()->LookupRegister(callee); | |
561 all[1] = environment()->LookupRegister(receiver); | |
562 int reciever_index = receiver.index(); | |
563 for (int i = 2; i < arity; ++i) { | |
564 all[i] = environment()->LookupRegister( | |
565 interpreter::Register(reciever_index + i - 1)); | |
566 } | |
567 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); | |
568 return value; | |
569 } | |
570 | |
571 | |
572 void BytecodeGraphBuilder::BuildCall( | |
573 const interpreter::BytecodeArrayIterator& iterator) { | |
574 // TODO(rmcilroy): Set receiver_hint correctly based on whether the reciever | |
575 // register has been loaded with null / undefined explicitly or we are sure it | |
oth
2015/11/13 12:24:06
s/reciever/receiver/
| |
576 // is not null / undefined. | |
577 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; | |
578 interpreter::Register callee = iterator.GetRegisterOperand(0); | |
579 interpreter::Register reciever = iterator.GetRegisterOperand(1); | |
oth
2015/11/13 12:24:06
s/reciever/receiver/
| |
580 size_t arg_count = iterator.GetCountOperand(2); | |
581 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(3)); | |
582 | |
583 const Operator* call = javascript()->CallFunction( | |
584 arg_count + 2, language_mode(), feedback, receiver_hint); | |
585 Node* value = ProcessCallArguments(call, callee, reciever, arg_count + 2); | |
586 AddEmptyFrameStateInputs(value); | |
587 environment()->BindAccumulator(value); | |
588 } | |
589 | |
590 | |
555 void BytecodeGraphBuilder::VisitCall( | 591 void BytecodeGraphBuilder::VisitCall( |
556 const interpreter::BytecodeArrayIterator& iterator) { | 592 const interpreter::BytecodeArrayIterator& iterator) { |
557 UNIMPLEMENTED(); | 593 BuildCall(iterator); |
558 } | 594 } |
559 | 595 |
560 | 596 |
597 void BytecodeGraphBuilder::VisitCallWide( | |
598 const interpreter::BytecodeArrayIterator& iterator) { | |
599 BuildCall(iterator); | |
600 } | |
601 | |
602 | |
561 void BytecodeGraphBuilder::VisitCallRuntime( | 603 void BytecodeGraphBuilder::VisitCallRuntime( |
562 const interpreter::BytecodeArrayIterator& iterator) { | 604 const interpreter::BytecodeArrayIterator& iterator) { |
563 UNIMPLEMENTED(); | 605 UNIMPLEMENTED(); |
564 } | 606 } |
565 | 607 |
566 | 608 |
567 void BytecodeGraphBuilder::VisitCallJSRuntime( | 609 void BytecodeGraphBuilder::VisitCallJSRuntime( |
568 const interpreter::BytecodeArrayIterator& iterator) { | 610 const interpreter::BytecodeArrayIterator& iterator) { |
569 UNIMPLEMENTED(); | 611 UNIMPLEMENTED(); |
570 } | 612 } |
(...skipping 10 matching lines...) Expand all Loading... | |
581 UNIMPLEMENTED(); | 623 UNIMPLEMENTED(); |
582 } | 624 } |
583 | 625 |
584 | 626 |
585 void BytecodeGraphBuilder::BuildBinaryOp( | 627 void BytecodeGraphBuilder::BuildBinaryOp( |
586 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { | 628 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { |
587 Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 629 Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0)); |
588 Node* right = environment()->LookupAccumulator(); | 630 Node* right = environment()->LookupAccumulator(); |
589 Node* node = NewNode(js_op, left, right); | 631 Node* node = NewNode(js_op, left, right); |
590 | 632 |
591 // TODO(oth): Real frame state and environment check pointing. | |
592 AddEmptyFrameStateInputs(node); | 633 AddEmptyFrameStateInputs(node); |
593 environment()->BindAccumulator(node); | 634 environment()->BindAccumulator(node); |
594 } | 635 } |
595 | 636 |
596 | 637 |
597 void BytecodeGraphBuilder::VisitAdd( | 638 void BytecodeGraphBuilder::VisitAdd( |
598 const interpreter::BytecodeArrayIterator& iterator) { | 639 const interpreter::BytecodeArrayIterator& iterator) { |
599 BuildBinaryOp(javascript()->Add(language_mode()), iterator); | 640 BuildBinaryOp(javascript()->Add(language_mode()), iterator); |
600 } | 641 } |
601 | 642 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
986 | 1027 |
987 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { | 1028 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { |
988 if (environment()->IsMarkedAsUnreachable()) return; | 1029 if (environment()->IsMarkedAsUnreachable()) return; |
989 environment()->MarkAsUnreachable(); | 1030 environment()->MarkAsUnreachable(); |
990 exit_controls_.push_back(exit); | 1031 exit_controls_.push_back(exit); |
991 } | 1032 } |
992 | 1033 |
993 } // namespace compiler | 1034 } // namespace compiler |
994 } // namespace internal | 1035 } // namespace internal |
995 } // namespace v8 | 1036 } // namespace v8 |
OLD | NEW |