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

Side by Side Diff: src/compiler/js-intrinsic-lowering.cc

Issue 1617503003: [Atomics] code stubs for atomic operations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: call code stub from TF Created 4 years, 10 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
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/js-intrinsic-lowering.h" 5 #include "src/compiler/js-intrinsic-lowering.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
11 #include "src/compiler/js-graph.h" 11 #include "src/compiler/js-graph.h"
12 #include "src/compiler/linkage.h" 12 #include "src/compiler/linkage.h"
13 #include "src/compiler/node-matchers.h" 13 #include "src/compiler/node-matchers.h"
14 #include "src/compiler/node-properties.h" 14 #include "src/compiler/node-properties.h"
15 #include "src/compiler/operator-properties.h" 15 #include "src/compiler/operator-properties.h"
16 #include "src/counters.h" 16 #include "src/counters.h"
17 #include "src/objects-inl.h" 17 #include "src/objects-inl.h"
18 #include "src/type-cache.h" 18 #include "src/type-cache.h"
19 19
20 namespace v8 { 20 namespace v8 {
21 namespace internal { 21 namespace internal {
22 namespace compiler { 22 namespace compiler {
23 23
24 // TODO(binji): copied from js-generic-lowering.cc, combine?
25 static CallDescriptor::Flags AdjustFrameStatesForCall(Node* node) {
Jarin 2016/01/28 08:11:12 I believe here you only need a simpler version bec
binji 2016/01/28 16:20:01 No, I think I was ending up with multiple frame st
Jarin 2016/02/01 07:42:43 What I am saying is that you should not adapt base
26 int count = OperatorProperties::GetFrameStateInputCount(node->op());
27 if (count > 1) {
28 int index = NodeProperties::FirstFrameStateIndex(node) + 1;
29 do {
30 node->RemoveInput(index);
31 } while (--count > 1);
32 }
33 return count > 0 ? CallDescriptor::kNeedsFrameState
34 : CallDescriptor::kNoFlags;
35 }
36
24 JSIntrinsicLowering::JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph, 37 JSIntrinsicLowering::JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph,
25 DeoptimizationMode mode) 38 DeoptimizationMode mode)
26 : AdvancedReducer(editor), 39 : AdvancedReducer(editor),
27 jsgraph_(jsgraph), 40 jsgraph_(jsgraph),
28 mode_(mode), 41 mode_(mode),
29 type_cache_(TypeCache::Get()) {} 42 type_cache_(TypeCache::Get()) {}
30 43
31 44
32 Reduction JSIntrinsicLowering::Reduce(Node* node) { 45 Reduction JSIntrinsicLowering::Reduce(Node* node) {
33 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange(); 46 if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 case Runtime::kInlineToPrimitive: 113 case Runtime::kInlineToPrimitive:
101 return ReduceToPrimitive(node); 114 return ReduceToPrimitive(node);
102 case Runtime::kInlineToString: 115 case Runtime::kInlineToString:
103 return ReduceToString(node); 116 return ReduceToString(node);
104 case Runtime::kInlineCall: 117 case Runtime::kInlineCall:
105 return ReduceCall(node); 118 return ReduceCall(node);
106 case Runtime::kInlineTailCall: 119 case Runtime::kInlineTailCall:
107 return ReduceTailCall(node); 120 return ReduceTailCall(node);
108 case Runtime::kInlineGetSuperConstructor: 121 case Runtime::kInlineGetSuperConstructor:
109 return ReduceGetSuperConstructor(node); 122 return ReduceGetSuperConstructor(node);
123 case Runtime::kInlineAtomicsLoad:
124 return ReduceAtomicsLoad(node);
110 default: 125 default:
111 break; 126 break;
112 } 127 }
113 return NoChange(); 128 return NoChange();
114 } 129 }
115 130
116 131
117 Reduction JSIntrinsicLowering::ReduceCreateIterResultObject(Node* node) { 132 Reduction JSIntrinsicLowering::ReduceCreateIterResultObject(Node* node) {
118 Node* const value = NodeProperties::GetValueInput(node, 0); 133 Node* const value = NodeProperties::GetValueInput(node, 0);
119 Node* const done = NodeProperties::GetValueInput(node, 1); 134 Node* const done = NodeProperties::GetValueInput(node, 1);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 Node* store = (graph()->NewNode( 479 Node* store = (graph()->NewNode(
465 simplified()->StoreElement(AccessBuilder::ForFixedArrayElement()), base, 480 simplified()->StoreElement(AccessBuilder::ForFixedArrayElement()), base,
466 index, value, effect, control)); 481 index, value, effect, control));
467 ReplaceWithValue(node, value, store); 482 ReplaceWithValue(node, value, store);
468 return Changed(store); 483 return Changed(store);
469 } 484 }
470 485
471 486
472 Reduction JSIntrinsicLowering::ReduceRegExpConstructResult(Node* node) { 487 Reduction JSIntrinsicLowering::ReduceRegExpConstructResult(Node* node) {
473 // TODO(bmeurer): Introduce JSCreateRegExpResult? 488 // TODO(bmeurer): Introduce JSCreateRegExpResult?
474 return Change(node, CodeFactory::RegExpConstructResult(isolate()), 0); 489 return Change(node, CodeFactory::RegExpConstructResult(isolate()), 0,
490 CallDescriptor::kNeedsFrameState);
475 } 491 }
476 492
477 493
478 Reduction JSIntrinsicLowering::ReduceRegExpExec(Node* node) { 494 Reduction JSIntrinsicLowering::ReduceRegExpExec(Node* node) {
479 return Change(node, CodeFactory::RegExpExec(isolate()), 4); 495 return Change(node, CodeFactory::RegExpExec(isolate()), 4,
496 CallDescriptor::kNeedsFrameState);
480 } 497 }
481 498
482 499
483 Reduction JSIntrinsicLowering::ReduceRegExpFlags(Node* node) { 500 Reduction JSIntrinsicLowering::ReduceRegExpFlags(Node* node) {
484 Node* const receiver = NodeProperties::GetValueInput(node, 0); 501 Node* const receiver = NodeProperties::GetValueInput(node, 0);
485 Node* const effect = NodeProperties::GetEffectInput(node); 502 Node* const effect = NodeProperties::GetEffectInput(node);
486 Node* const control = NodeProperties::GetControlInput(node); 503 Node* const control = NodeProperties::GetControlInput(node);
487 Operator const* const op = 504 Operator const* const op =
488 simplified()->LoadField(AccessBuilder::ForJSRegExpFlags()); 505 simplified()->LoadField(AccessBuilder::ForJSRegExpFlags());
489 return Change(node, op, receiver, effect, control); 506 return Change(node, op, receiver, effect, control);
490 } 507 }
491 508
492 509
493 Reduction JSIntrinsicLowering::ReduceRegExpSource(Node* node) { 510 Reduction JSIntrinsicLowering::ReduceRegExpSource(Node* node) {
494 Node* const receiver = NodeProperties::GetValueInput(node, 0); 511 Node* const receiver = NodeProperties::GetValueInput(node, 0);
495 Node* const effect = NodeProperties::GetEffectInput(node); 512 Node* const effect = NodeProperties::GetEffectInput(node);
496 Node* const control = NodeProperties::GetControlInput(node); 513 Node* const control = NodeProperties::GetControlInput(node);
497 Operator const* const op = 514 Operator const* const op =
498 simplified()->LoadField(AccessBuilder::ForJSRegExpSource()); 515 simplified()->LoadField(AccessBuilder::ForJSRegExpSource());
499 return Change(node, op, receiver, effect, control); 516 return Change(node, op, receiver, effect, control);
500 } 517 }
501 518
502 519
503 Reduction JSIntrinsicLowering::ReduceSubString(Node* node) { 520 Reduction JSIntrinsicLowering::ReduceSubString(Node* node) {
504 return Change(node, CodeFactory::SubString(isolate()), 3); 521 return Change(node, CodeFactory::SubString(isolate()), 3,
522 CallDescriptor::kNeedsFrameState);
505 } 523 }
506 524
507 525
508 Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) { 526 Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) {
509 Node* value = NodeProperties::GetValueInput(node, 0); 527 Node* value = NodeProperties::GetValueInput(node, 0);
510 Type* value_type = NodeProperties::GetType(value); 528 Type* value_type = NodeProperties::GetType(value);
511 if (value_type->Is(type_cache().kIntegerOrMinusZero)) { 529 if (value_type->Is(type_cache().kIntegerOrMinusZero)) {
512 ReplaceWithValue(node, value); 530 ReplaceWithValue(node, value);
513 return Replace(value); 531 return Replace(value);
514 } 532 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 jsgraph()->Constant(kMaxSafeInteger), value), 571 jsgraph()->Constant(kMaxSafeInteger), value),
554 jsgraph()->Constant(kMaxSafeInteger), value); 572 jsgraph()->Constant(kMaxSafeInteger), value);
555 value_type = 573 value_type =
556 Type::Range(value_type->Min(), kMaxSafeInteger, graph()->zone()); 574 Type::Range(value_type->Min(), kMaxSafeInteger, graph()->zone());
557 NodeProperties::SetType(value, value_type); 575 NodeProperties::SetType(value, value_type);
558 } 576 }
559 } 577 }
560 ReplaceWithValue(node, value); 578 ReplaceWithValue(node, value);
561 return Replace(value); 579 return Replace(value);
562 } 580 }
563 return Change(node, CodeFactory::ToLength(isolate()), 0); 581 return Change(node, CodeFactory::ToLength(isolate()), 0,
582 CallDescriptor::kNeedsFrameState);
564 } 583 }
565 584
566 585
567 Reduction JSIntrinsicLowering::ReduceToObject(Node* node) { 586 Reduction JSIntrinsicLowering::ReduceToObject(Node* node) {
568 NodeProperties::ChangeOp(node, javascript()->ToObject()); 587 NodeProperties::ChangeOp(node, javascript()->ToObject());
569 return Changed(node); 588 return Changed(node);
570 } 589 }
571 590
572 591
573 Reduction JSIntrinsicLowering::ReduceToPrimitive(Node* node) { 592 Reduction JSIntrinsicLowering::ReduceToPrimitive(Node* node) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 Node* active_function = NodeProperties::GetValueInput(node, 0); 630 Node* active_function = NodeProperties::GetValueInput(node, 0);
612 Node* effect = NodeProperties::GetEffectInput(node); 631 Node* effect = NodeProperties::GetEffectInput(node);
613 Node* control = NodeProperties::GetControlInput(node); 632 Node* control = NodeProperties::GetControlInput(node);
614 Node* active_function_map = effect = 633 Node* active_function_map = effect =
615 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), 634 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()),
616 active_function, effect, control); 635 active_function, effect, control);
617 return Change(node, simplified()->LoadField(AccessBuilder::ForMapPrototype()), 636 return Change(node, simplified()->LoadField(AccessBuilder::ForMapPrototype()),
618 active_function_map, effect, control); 637 active_function_map, effect, control);
619 } 638 }
620 639
640 Reduction JSIntrinsicLowering::ReduceAtomicsLoad(Node* node) {
641 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
642 return Change(node, CodeFactory::AtomicsLoad(isolate()), 0, flags);
643 }
621 644
622 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, 645 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a,
623 Node* b) { 646 Node* b) {
624 RelaxControls(node); 647 RelaxControls(node);
625 node->ReplaceInput(0, a); 648 node->ReplaceInput(0, a);
626 node->ReplaceInput(1, b); 649 node->ReplaceInput(1, b);
627 node->TrimInputCount(2); 650 node->TrimInputCount(2);
628 NodeProperties::ChangeOp(node, op); 651 NodeProperties::ChangeOp(node, op);
629 return Changed(node); 652 return Changed(node);
630 } 653 }
(...skipping 22 matching lines...) Expand all
653 NodeProperties::ChangeOp(node, op); 676 NodeProperties::ChangeOp(node, op);
654 return Changed(node); 677 return Changed(node);
655 } 678 }
656 679
657 680
658 Reduction JSIntrinsicLowering::ChangeToUndefined(Node* node, Node* effect) { 681 Reduction JSIntrinsicLowering::ChangeToUndefined(Node* node, Node* effect) {
659 ReplaceWithValue(node, jsgraph()->UndefinedConstant(), effect); 682 ReplaceWithValue(node, jsgraph()->UndefinedConstant(), effect);
660 return Changed(node); 683 return Changed(node);
661 } 684 }
662 685
663
664 Reduction JSIntrinsicLowering::Change(Node* node, Callable const& callable, 686 Reduction JSIntrinsicLowering::Change(Node* node, Callable const& callable,
665 int stack_parameter_count) { 687 int stack_parameter_count,
688 CallDescriptor::Flags flags) {
666 CallDescriptor const* const desc = Linkage::GetStubCallDescriptor( 689 CallDescriptor const* const desc = Linkage::GetStubCallDescriptor(
667 isolate(), graph()->zone(), callable.descriptor(), stack_parameter_count, 690 isolate(), graph()->zone(), callable.descriptor(), stack_parameter_count,
668 CallDescriptor::kNeedsFrameState, node->op()->properties()); 691 flags, node->op()->properties());
669 node->InsertInput(graph()->zone(), 0, 692 node->InsertInput(graph()->zone(), 0,
670 jsgraph()->HeapConstant(callable.code())); 693 jsgraph()->HeapConstant(callable.code()));
671 NodeProperties::ChangeOp(node, common()->Call(desc)); 694 NodeProperties::ChangeOp(node, common()->Call(desc));
672 return Changed(node); 695 return Changed(node);
673 } 696 }
674 697
675 698
676 Graph* JSIntrinsicLowering::graph() const { return jsgraph()->graph(); } 699 Graph* JSIntrinsicLowering::graph() const { return jsgraph()->graph(); }
677 700
678 701
(...skipping 14 matching lines...) Expand all
693 } 716 }
694 717
695 718
696 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { 719 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const {
697 return jsgraph()->simplified(); 720 return jsgraph()->simplified();
698 } 721 }
699 722
700 } // namespace compiler 723 } // namespace compiler
701 } // namespace internal 724 } // namespace internal
702 } // namespace v8 725 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698