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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 613683002: [turbofan] Some javascript operators are globally shared singletons. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/change-lowering.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/control-builders.h" 8 #include "src/compiler/control-builders.h"
9 #include "src/compiler/machine-operator.h" 9 #include "src/compiler/machine-operator.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 Node* inner = BuildLocalFunctionContext(outer, closure); 68 Node* inner = BuildLocalFunctionContext(outer, closure);
69 69
70 // Push top-level function scope for the function body. 70 // Push top-level function scope for the function body.
71 ContextScope top_context(this, scope, inner); 71 ContextScope top_context(this, scope, inner);
72 72
73 // Build the arguments object if it is used. 73 // Build the arguments object if it is used.
74 BuildArgumentsObject(scope->arguments()); 74 BuildArgumentsObject(scope->arguments());
75 75
76 // Emit tracing call if requested to do so. 76 // Emit tracing call if requested to do so.
77 if (FLAG_trace) { 77 if (FLAG_trace) {
78 NewNode(javascript()->Runtime(Runtime::kTraceEnter, 0)); 78 NewNode(javascript()->CallRuntime(Runtime::kTraceEnter, 0));
79 } 79 }
80 80
81 // Visit implicit declaration of the function name. 81 // Visit implicit declaration of the function name.
82 if (scope->is_function_scope() && scope->function() != NULL) { 82 if (scope->is_function_scope() && scope->function() != NULL) {
83 VisitVariableDeclaration(scope->function()); 83 VisitVariableDeclaration(scope->function());
84 } 84 }
85 85
86 // Visit declarations within the function scope. 86 // Visit declarations within the function scope.
87 VisitDeclarations(scope->declarations()); 87 VisitDeclarations(scope->declarations());
88 88
89 // TODO(mstarzinger): This should do an inlined stack check. 89 // TODO(mstarzinger): This should do an inlined stack check.
90 Node* node = NewNode(javascript()->Runtime(Runtime::kStackGuard, 0)); 90 Node* node = NewNode(javascript()->CallRuntime(Runtime::kStackGuard, 0));
91 PrepareFrameState(node, BailoutId::FunctionEntry()); 91 PrepareFrameState(node, BailoutId::FunctionEntry());
92 92
93 // Visit statements in the function body. 93 // Visit statements in the function body.
94 VisitStatements(info()->function()->body()); 94 VisitStatements(info()->function()->body());
95 if (HasStackOverflow()) return false; 95 if (HasStackOverflow()) return false;
96 96
97 // Emit tracing call if requested to do so. 97 // Emit tracing call if requested to do so.
98 if (FLAG_trace) { 98 if (FLAG_trace) {
99 // TODO(mstarzinger): Only traces implicit return. 99 // TODO(mstarzinger): Only traces implicit return.
100 Node* return_value = jsgraph()->UndefinedConstant(); 100 Node* return_value = jsgraph()->UndefinedConstant();
101 NewNode(javascript()->Runtime(Runtime::kTraceExit, 1), return_value); 101 NewNode(javascript()->CallRuntime(Runtime::kTraceExit, 1), return_value);
102 } 102 }
103 103
104 // Return 'undefined' in case we can fall off the end. 104 // Return 'undefined' in case we can fall off the end.
105 Node* control = NewNode(common()->Return(), jsgraph()->UndefinedConstant()); 105 Node* control = NewNode(common()->Return(), jsgraph()->UndefinedConstant());
106 UpdateControlDependencyToLeaveFunction(control); 106 UpdateControlDependencyToLeaveFunction(control);
107 107
108 // Finish the basic structure of the graph. 108 // Finish the basic structure of the graph.
109 environment()->UpdateControlDependency(exit_control()); 109 environment()->UpdateControlDependency(exit_control());
110 graph()->SetEnd(NewNode(common()->End())); 110 graph()->SetEnd(NewNode(common()->End()));
111 111
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 is_null.If(is_null_cond); 636 is_null.If(is_null_cond);
637 is_null.Then(); 637 is_null.Then();
638 is_null.Else(); 638 is_null.Else();
639 // Convert object to jsobject. 639 // Convert object to jsobject.
640 // PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); 640 // PrepareForBailoutForId(stmt->PrepareId(), TOS_REG);
641 obj = NewNode(javascript()->ToObject(), obj); 641 obj = NewNode(javascript()->ToObject(), obj);
642 environment()->Push(obj); 642 environment()->Push(obj);
643 // TODO(dcarney): should do a fast enum cache check here to skip runtime. 643 // TODO(dcarney): should do a fast enum cache check here to skip runtime.
644 environment()->Push(obj); 644 environment()->Push(obj);
645 Node* cache_type = ProcessArguments( 645 Node* cache_type = ProcessArguments(
646 javascript()->Runtime(Runtime::kGetPropertyNamesFast, 1), 1); 646 javascript()->CallRuntime(Runtime::kGetPropertyNamesFast, 1), 1);
647 // TODO(dcarney): these next runtime calls should be removed in favour of 647 // TODO(dcarney): these next runtime calls should be removed in favour of
648 // a few simplified instructions. 648 // a few simplified instructions.
649 environment()->Push(obj); 649 environment()->Push(obj);
650 environment()->Push(cache_type); 650 environment()->Push(cache_type);
651 Node* cache_pair = 651 Node* cache_pair =
652 ProcessArguments(javascript()->Runtime(Runtime::kForInInit, 2), 2); 652 ProcessArguments(javascript()->CallRuntime(Runtime::kForInInit, 2), 2);
653 // cache_type may have been replaced. 653 // cache_type may have been replaced.
654 Node* cache_array = NewNode(common()->Projection(0), cache_pair); 654 Node* cache_array = NewNode(common()->Projection(0), cache_pair);
655 cache_type = NewNode(common()->Projection(1), cache_pair); 655 cache_type = NewNode(common()->Projection(1), cache_pair);
656 environment()->Push(cache_type); 656 environment()->Push(cache_type);
657 environment()->Push(cache_array); 657 environment()->Push(cache_array);
658 Node* cache_length = ProcessArguments( 658 Node* cache_length = ProcessArguments(
659 javascript()->Runtime(Runtime::kForInCacheArrayLength, 2), 2); 659 javascript()->CallRuntime(Runtime::kForInCacheArrayLength, 2), 2);
660 { 660 {
661 // TODO(dcarney): this check is actually supposed to be for the 661 // TODO(dcarney): this check is actually supposed to be for the
662 // empty enum case only. 662 // empty enum case only.
663 IfBuilder have_no_properties(this); 663 IfBuilder have_no_properties(this);
664 Node* empty_array_cond = NewNode(javascript()->StrictEqual(), 664 Node* empty_array_cond = NewNode(javascript()->StrictEqual(),
665 cache_length, jsgraph()->ZeroConstant()); 665 cache_length, jsgraph()->ZeroConstant());
666 have_no_properties.If(empty_array_cond); 666 have_no_properties.If(empty_array_cond);
667 have_no_properties.Then(); 667 have_no_properties.Then();
668 // Pop obj and skip loop. 668 // Pop obj and skip loop.
669 environment()->Pop(); 669 environment()->Pop();
(...skipping 15 matching lines...) Expand all
685 PrepareFrameState(exit_cond, BailoutId::None()); 685 PrepareFrameState(exit_cond, BailoutId::None());
686 for_loop.BreakUnless(exit_cond); 686 for_loop.BreakUnless(exit_cond);
687 // TODO(dcarney): this runtime call should be a handful of 687 // TODO(dcarney): this runtime call should be a handful of
688 // simplified instructions that 688 // simplified instructions that
689 // basically produce 689 // basically produce
690 // value = array[index] 690 // value = array[index]
691 environment()->Push(obj); 691 environment()->Push(obj);
692 environment()->Push(cache_array); 692 environment()->Push(cache_array);
693 environment()->Push(cache_type); 693 environment()->Push(cache_type);
694 environment()->Push(index); 694 environment()->Push(index);
695 Node* pair = 695 Node* pair = ProcessArguments(
696 ProcessArguments(javascript()->Runtime(Runtime::kForInNext, 4), 4); 696 javascript()->CallRuntime(Runtime::kForInNext, 4), 4);
697 Node* value = NewNode(common()->Projection(0), pair); 697 Node* value = NewNode(common()->Projection(0), pair);
698 Node* should_filter = NewNode(common()->Projection(1), pair); 698 Node* should_filter = NewNode(common()->Projection(1), pair);
699 environment()->Push(value); 699 environment()->Push(value);
700 { 700 {
701 // Test if FILTER_KEY needs to be called. 701 // Test if FILTER_KEY needs to be called.
702 IfBuilder test_should_filter(this); 702 IfBuilder test_should_filter(this);
703 Node* should_filter_cond = 703 Node* should_filter_cond =
704 NewNode(javascript()->StrictEqual(), should_filter, 704 NewNode(javascript()->StrictEqual(), should_filter,
705 jsgraph()->TrueConstant()); 705 jsgraph()->TrueConstant());
706 test_should_filter.If(should_filter_cond); 706 test_should_filter.If(should_filter_cond);
707 test_should_filter.Then(); 707 test_should_filter.Then();
708 value = environment()->Pop(); 708 value = environment()->Pop();
709 Node* builtins = BuildLoadBuiltinsObject(); 709 Node* builtins = BuildLoadBuiltinsObject();
710 Node* function = BuildLoadObjectField( 710 Node* function = BuildLoadObjectField(
711 builtins, 711 builtins,
712 JSBuiltinsObject::OffsetOfFunctionWithId(Builtins::FILTER_KEY)); 712 JSBuiltinsObject::OffsetOfFunctionWithId(Builtins::FILTER_KEY));
713 // Callee. 713 // Callee.
714 environment()->Push(function); 714 environment()->Push(function);
715 // Receiver. 715 // Receiver.
716 environment()->Push(obj); 716 environment()->Push(obj);
717 // Args. 717 // Args.
718 environment()->Push(value); 718 environment()->Push(value);
719 // result is either the string key or Smi(0) indicating the property 719 // result is either the string key or Smi(0) indicating the property
720 // is gone. 720 // is gone.
721 Node* res = ProcessArguments( 721 Node* res = ProcessArguments(
722 javascript()->Call(3, NO_CALL_FUNCTION_FLAGS), 3); 722 javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS), 3);
723 // TODO(jarin): provide real bailout id. 723 // TODO(jarin): provide real bailout id.
724 PrepareFrameState(res, BailoutId::None()); 724 PrepareFrameState(res, BailoutId::None());
725 Node* property_missing = NewNode(javascript()->StrictEqual(), res, 725 Node* property_missing = NewNode(javascript()->StrictEqual(), res,
726 jsgraph()->ZeroConstant()); 726 jsgraph()->ZeroConstant());
727 { 727 {
728 IfBuilder is_property_missing(this); 728 IfBuilder is_property_missing(this);
729 is_property_missing.If(property_missing); 729 is_property_missing.If(property_missing);
730 is_property_missing.Then(); 730 is_property_missing.Then();
731 // Inc counter and continue. 731 // Inc counter and continue.
732 Node* index_inc = 732 Node* index_inc =
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 778 }
779 779
780 780
781 void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) { 781 void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
782 UNREACHABLE(); 782 UNREACHABLE();
783 } 783 }
784 784
785 785
786 void AstGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) { 786 void AstGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) {
787 // TODO(turbofan): Do we really need a separate reloc-info for this? 787 // TODO(turbofan): Do we really need a separate reloc-info for this?
788 Node* node = NewNode(javascript()->Runtime(Runtime::kDebugBreak, 0)); 788 Node* node = NewNode(javascript()->CallRuntime(Runtime::kDebugBreak, 0));
789 PrepareFrameState(node, stmt->DebugBreakId()); 789 PrepareFrameState(node, stmt->DebugBreakId());
790 } 790 }
791 791
792 792
793 void AstGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { 793 void AstGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) {
794 Node* context = current_context(); 794 Node* context = current_context();
795 795
796 // Build a new shared function info if we cannot find one in the baseline 796 // Build a new shared function info if we cannot find one in the baseline
797 // code. We also have a stack overflow if the recursive compilation did. 797 // code. We also have a stack overflow if the recursive compilation did.
798 Handle<SharedFunctionInfo> shared_info = 798 Handle<SharedFunctionInfo> shared_info =
799 SearchSharedFunctionInfo(info()->shared_info()->code(), expr); 799 SearchSharedFunctionInfo(info()->shared_info()->code(), expr);
800 if (shared_info.is_null()) { 800 if (shared_info.is_null()) {
801 shared_info = Compiler::BuildFunctionInfo(expr, info()->script(), info()); 801 shared_info = Compiler::BuildFunctionInfo(expr, info()->script(), info());
802 CHECK(!shared_info.is_null()); // TODO(mstarzinger): Set stack overflow? 802 CHECK(!shared_info.is_null()); // TODO(mstarzinger): Set stack overflow?
803 } 803 }
804 804
805 // Create node to instantiate a new closure. 805 // Create node to instantiate a new closure.
806 Node* info = jsgraph()->Constant(shared_info); 806 Node* info = jsgraph()->Constant(shared_info);
807 Node* pretenure = expr->pretenure() ? jsgraph()->TrueConstant() 807 Node* pretenure = expr->pretenure() ? jsgraph()->TrueConstant()
808 : jsgraph()->FalseConstant(); 808 : jsgraph()->FalseConstant();
809 const Operator* op = javascript()->Runtime(Runtime::kNewClosure, 3); 809 const Operator* op = javascript()->CallRuntime(Runtime::kNewClosure, 3);
810 Node* value = NewNode(op, context, info, pretenure); 810 Node* value = NewNode(op, context, info, pretenure);
811 ast_context()->ProduceValue(value); 811 ast_context()->ProduceValue(value);
812 } 812 }
813 813
814 814
815 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) { 815 void AstGraphBuilder::VisitClassLiteral(ClassLiteral* expr) {
816 // TODO(arv): Implement. 816 // TODO(arv): Implement.
817 UNREACHABLE(); 817 UNREACHABLE();
818 } 818 }
819 819
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 void AstGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { 852 void AstGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) {
853 Node* closure = GetFunctionClosure(); 853 Node* closure = GetFunctionClosure();
854 854
855 // Create node to materialize a regular expression literal. 855 // Create node to materialize a regular expression literal.
856 Node* literals_array = 856 Node* literals_array =
857 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); 857 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset);
858 Node* literal_index = jsgraph()->Constant(expr->literal_index()); 858 Node* literal_index = jsgraph()->Constant(expr->literal_index());
859 Node* pattern = jsgraph()->Constant(expr->pattern()); 859 Node* pattern = jsgraph()->Constant(expr->pattern());
860 Node* flags = jsgraph()->Constant(expr->flags()); 860 Node* flags = jsgraph()->Constant(expr->flags());
861 const Operator* op = 861 const Operator* op =
862 javascript()->Runtime(Runtime::kMaterializeRegExpLiteral, 4); 862 javascript()->CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
863 Node* literal = NewNode(op, literals_array, literal_index, pattern, flags); 863 Node* literal = NewNode(op, literals_array, literal_index, pattern, flags);
864 PrepareFrameState(literal, expr->id(), ast_context()->GetStateCombine()); 864 PrepareFrameState(literal, expr->id(), ast_context()->GetStateCombine());
865 ast_context()->ProduceValue(literal); 865 ast_context()->ProduceValue(literal);
866 } 866 }
867 867
868 868
869 void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { 869 void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
870 Node* closure = GetFunctionClosure(); 870 Node* closure = GetFunctionClosure();
871 871
872 // Create node to deep-copy the literal boilerplate. 872 // Create node to deep-copy the literal boilerplate.
873 expr->BuildConstantProperties(isolate()); 873 expr->BuildConstantProperties(isolate());
874 Node* literals_array = 874 Node* literals_array =
875 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); 875 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset);
876 Node* literal_index = jsgraph()->Constant(expr->literal_index()); 876 Node* literal_index = jsgraph()->Constant(expr->literal_index());
877 Node* constants = jsgraph()->Constant(expr->constant_properties()); 877 Node* constants = jsgraph()->Constant(expr->constant_properties());
878 Node* flags = jsgraph()->Constant(expr->ComputeFlags()); 878 Node* flags = jsgraph()->Constant(expr->ComputeFlags());
879 const Operator* op = javascript()->Runtime(Runtime::kCreateObjectLiteral, 4); 879 const Operator* op =
880 javascript()->CallRuntime(Runtime::kCreateObjectLiteral, 4);
880 Node* literal = NewNode(op, literals_array, literal_index, constants, flags); 881 Node* literal = NewNode(op, literals_array, literal_index, constants, flags);
881 882
882 // The object is expected on the operand stack during computation of the 883 // The object is expected on the operand stack during computation of the
883 // property values and is the value of the entire expression. 884 // property values and is the value of the entire expression.
884 environment()->Push(literal); 885 environment()->Push(literal);
885 886
886 // Mark all computed expressions that are bound to a key that is shadowed by 887 // Mark all computed expressions that are bound to a key that is shadowed by
887 // a later occurrence of the same key. For the marked expressions, no store 888 // a later occurrence of the same key. For the marked expressions, no store
888 // code is emitted. 889 // code is emitted.
889 expr->CalculateEmitStore(zone()); 890 expr->CalculateEmitStore(zone());
(...skipping 28 matching lines...) Expand all
918 break; 919 break;
919 } 920 }
920 environment()->Push(literal); // Duplicate receiver. 921 environment()->Push(literal); // Duplicate receiver.
921 VisitForValue(property->key()); 922 VisitForValue(property->key());
922 VisitForValue(property->value()); 923 VisitForValue(property->value());
923 Node* value = environment()->Pop(); 924 Node* value = environment()->Pop();
924 Node* key = environment()->Pop(); 925 Node* key = environment()->Pop();
925 Node* receiver = environment()->Pop(); 926 Node* receiver = environment()->Pop();
926 if (property->emit_store()) { 927 if (property->emit_store()) {
927 Node* strict = jsgraph()->Constant(SLOPPY); 928 Node* strict = jsgraph()->Constant(SLOPPY);
928 const Operator* op = javascript()->Runtime(Runtime::kSetProperty, 4); 929 const Operator* op =
930 javascript()->CallRuntime(Runtime::kSetProperty, 4);
929 NewNode(op, receiver, key, value, strict); 931 NewNode(op, receiver, key, value, strict);
930 } 932 }
931 break; 933 break;
932 } 934 }
933 case ObjectLiteral::Property::PROTOTYPE: { 935 case ObjectLiteral::Property::PROTOTYPE: {
934 environment()->Push(literal); // Duplicate receiver. 936 environment()->Push(literal); // Duplicate receiver.
935 VisitForValue(property->value()); 937 VisitForValue(property->value());
936 Node* value = environment()->Pop(); 938 Node* value = environment()->Pop();
937 Node* receiver = environment()->Pop(); 939 Node* receiver = environment()->Pop();
938 if (property->emit_store()) { 940 if (property->emit_store()) {
939 const Operator* op = javascript()->Runtime(Runtime::kSetPrototype, 2); 941 const Operator* op =
942 javascript()->CallRuntime(Runtime::kSetPrototype, 2);
940 NewNode(op, receiver, value); 943 NewNode(op, receiver, value);
941 } 944 }
942 break; 945 break;
943 } 946 }
944 case ObjectLiteral::Property::GETTER: 947 case ObjectLiteral::Property::GETTER:
945 accessor_table.lookup(key)->second->getter = property->value(); 948 accessor_table.lookup(key)->second->getter = property->value();
946 break; 949 break;
947 case ObjectLiteral::Property::SETTER: 950 case ObjectLiteral::Property::SETTER:
948 accessor_table.lookup(key)->second->setter = property->value(); 951 accessor_table.lookup(key)->second->setter = property->value();
949 break; 952 break;
950 } 953 }
951 } 954 }
952 955
953 // Create nodes to define accessors, using only a single call to the runtime 956 // Create nodes to define accessors, using only a single call to the runtime
954 // for each pair of corresponding getters and setters. 957 // for each pair of corresponding getters and setters.
955 for (AccessorTable::Iterator it = accessor_table.begin(); 958 for (AccessorTable::Iterator it = accessor_table.begin();
956 it != accessor_table.end(); ++it) { 959 it != accessor_table.end(); ++it) {
957 VisitForValue(it->first); 960 VisitForValue(it->first);
958 VisitForValueOrNull(it->second->getter); 961 VisitForValueOrNull(it->second->getter);
959 VisitForValueOrNull(it->second->setter); 962 VisitForValueOrNull(it->second->setter);
960 Node* setter = environment()->Pop(); 963 Node* setter = environment()->Pop();
961 Node* getter = environment()->Pop(); 964 Node* getter = environment()->Pop();
962 Node* name = environment()->Pop(); 965 Node* name = environment()->Pop();
963 Node* attr = jsgraph()->Constant(NONE); 966 Node* attr = jsgraph()->Constant(NONE);
964 const Operator* op = 967 const Operator* op =
965 javascript()->Runtime(Runtime::kDefineAccessorPropertyUnchecked, 5); 968 javascript()->CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
966 Node* call = NewNode(op, literal, name, getter, setter, attr); 969 Node* call = NewNode(op, literal, name, getter, setter, attr);
967 PrepareFrameState(call, it->first->id()); 970 PrepareFrameState(call, it->first->id());
968 } 971 }
969 972
970 // Transform literals that contain functions to fast properties. 973 // Transform literals that contain functions to fast properties.
971 if (expr->has_function()) { 974 if (expr->has_function()) {
972 const Operator* op = javascript()->Runtime(Runtime::kToFastProperties, 1); 975 const Operator* op =
976 javascript()->CallRuntime(Runtime::kToFastProperties, 1);
973 NewNode(op, literal); 977 NewNode(op, literal);
974 } 978 }
975 979
976 ast_context()->ProduceValue(environment()->Pop()); 980 ast_context()->ProduceValue(environment()->Pop());
977 } 981 }
978 982
979 983
980 void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { 984 void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
981 Node* closure = GetFunctionClosure(); 985 Node* closure = GetFunctionClosure();
982 986
983 // Create node to deep-copy the literal boilerplate. 987 // Create node to deep-copy the literal boilerplate.
984 expr->BuildConstantElements(isolate()); 988 expr->BuildConstantElements(isolate());
985 Node* literals_array = 989 Node* literals_array =
986 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); 990 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset);
987 Node* literal_index = jsgraph()->Constant(expr->literal_index()); 991 Node* literal_index = jsgraph()->Constant(expr->literal_index());
988 Node* constants = jsgraph()->Constant(expr->constant_elements()); 992 Node* constants = jsgraph()->Constant(expr->constant_elements());
989 Node* flags = jsgraph()->Constant(expr->ComputeFlags()); 993 Node* flags = jsgraph()->Constant(expr->ComputeFlags());
990 const Operator* op = javascript()->Runtime(Runtime::kCreateArrayLiteral, 4); 994 const Operator* op =
995 javascript()->CallRuntime(Runtime::kCreateArrayLiteral, 4);
991 Node* literal = NewNode(op, literals_array, literal_index, constants, flags); 996 Node* literal = NewNode(op, literals_array, literal_index, constants, flags);
992 997
993 // The array and the literal index are both expected on the operand stack 998 // The array and the literal index are both expected on the operand stack
994 // during computation of the element values. 999 // during computation of the element values.
995 environment()->Push(literal); 1000 environment()->Push(literal);
996 environment()->Push(literal_index); 1001 environment()->Push(literal_index);
997 1002
998 // Create nodes to evaluate all the non-constant subexpressions and to store 1003 // Create nodes to evaluate all the non-constant subexpressions and to store
999 // them into the newly cloned array. 1004 // them into the newly cloned array.
1000 for (int i = 0; i < expr->values()->length(); i++) { 1005 for (int i = 0; i < expr->values()->length(); i++) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 environment()->Pop(); 1164 environment()->Pop();
1160 environment()->Pop(); 1165 environment()->Pop();
1161 // TODO(turbofan): VisitYield 1166 // TODO(turbofan): VisitYield
1162 ast_context()->ProduceValue(jsgraph()->UndefinedConstant()); 1167 ast_context()->ProduceValue(jsgraph()->UndefinedConstant());
1163 } 1168 }
1164 1169
1165 1170
1166 void AstGraphBuilder::VisitThrow(Throw* expr) { 1171 void AstGraphBuilder::VisitThrow(Throw* expr) {
1167 VisitForValue(expr->exception()); 1172 VisitForValue(expr->exception());
1168 Node* exception = environment()->Pop(); 1173 Node* exception = environment()->Pop();
1169 const Operator* op = javascript()->Runtime(Runtime::kThrow, 1); 1174 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1);
1170 Node* value = NewNode(op, exception); 1175 Node* value = NewNode(op, exception);
1171 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 1176 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
1172 ast_context()->ProduceValue(value); 1177 ast_context()->ProduceValue(value);
1173 } 1178 }
1174 1179
1175 1180
1176 void AstGraphBuilder::VisitProperty(Property* expr) { 1181 void AstGraphBuilder::VisitProperty(Property* expr) {
1177 Node* value; 1182 Node* value;
1178 if (expr->key()->IsPropertyName()) { 1183 if (expr->key()->IsPropertyName()) {
1179 VisitForValue(expr->obj()); 1184 VisitForValue(expr->obj());
(...skipping 26 matching lines...) Expand all
1206 case Call::GLOBAL_CALL: { 1211 case Call::GLOBAL_CALL: {
1207 Variable* variable = callee->AsVariableProxy()->var(); 1212 Variable* variable = callee->AsVariableProxy()->var();
1208 callee_value = BuildVariableLoad(variable, expr->expression()->id()); 1213 callee_value = BuildVariableLoad(variable, expr->expression()->id());
1209 receiver_value = jsgraph()->UndefinedConstant(); 1214 receiver_value = jsgraph()->UndefinedConstant();
1210 break; 1215 break;
1211 } 1216 }
1212 case Call::LOOKUP_SLOT_CALL: { 1217 case Call::LOOKUP_SLOT_CALL: {
1213 Variable* variable = callee->AsVariableProxy()->var(); 1218 Variable* variable = callee->AsVariableProxy()->var();
1214 DCHECK(variable->location() == Variable::LOOKUP); 1219 DCHECK(variable->location() == Variable::LOOKUP);
1215 Node* name = jsgraph()->Constant(variable->name()); 1220 Node* name = jsgraph()->Constant(variable->name());
1216 const Operator* op = javascript()->Runtime(Runtime::kLoadLookupSlot, 2); 1221 const Operator* op =
1222 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2);
1217 Node* pair = NewNode(op, current_context(), name); 1223 Node* pair = NewNode(op, current_context(), name);
1218 callee_value = NewNode(common()->Projection(0), pair); 1224 callee_value = NewNode(common()->Projection(0), pair);
1219 receiver_value = NewNode(common()->Projection(1), pair); 1225 receiver_value = NewNode(common()->Projection(1), pair);
1220 1226
1221 PrepareFrameState(pair, expr->EvalOrLookupId(), 1227 PrepareFrameState(pair, expr->EvalOrLookupId(),
1222 OutputFrameStateCombine::Push()); 1228 OutputFrameStateCombine::Push());
1223 break; 1229 break;
1224 } 1230 }
1225 case Call::PROPERTY_CALL: { 1231 case Call::PROPERTY_CALL: {
1226 Property* property = callee->AsProperty(); 1232 Property* property = callee->AsProperty();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 // Extract callee and source string from the environment. 1277 // Extract callee and source string from the environment.
1272 Node* callee = environment()->Peek(arg_count + 1); 1278 Node* callee = environment()->Peek(arg_count + 1);
1273 Node* source = environment()->Peek(arg_count - 1); 1279 Node* source = environment()->Peek(arg_count - 1);
1274 1280
1275 // Create node to ask for help resolving potential eval call. This will 1281 // Create node to ask for help resolving potential eval call. This will
1276 // provide a fully resolved callee and the corresponding receiver. 1282 // provide a fully resolved callee and the corresponding receiver.
1277 Node* receiver = environment()->Lookup(info()->scope()->receiver()); 1283 Node* receiver = environment()->Lookup(info()->scope()->receiver());
1278 Node* strict = jsgraph()->Constant(strict_mode()); 1284 Node* strict = jsgraph()->Constant(strict_mode());
1279 Node* position = jsgraph()->Constant(info()->scope()->start_position()); 1285 Node* position = jsgraph()->Constant(info()->scope()->start_position());
1280 const Operator* op = 1286 const Operator* op =
1281 javascript()->Runtime(Runtime::kResolvePossiblyDirectEval, 5); 1287 javascript()->CallRuntime(Runtime::kResolvePossiblyDirectEval, 5);
1282 Node* pair = NewNode(op, callee, source, receiver, strict, position); 1288 Node* pair = NewNode(op, callee, source, receiver, strict, position);
1283 PrepareFrameState(pair, expr->EvalOrLookupId(), 1289 PrepareFrameState(pair, expr->EvalOrLookupId(),
1284 OutputFrameStateCombine::PokeAt(arg_count + 1)); 1290 OutputFrameStateCombine::PokeAt(arg_count + 1));
1285 Node* new_callee = NewNode(common()->Projection(0), pair); 1291 Node* new_callee = NewNode(common()->Projection(0), pair);
1286 Node* new_receiver = NewNode(common()->Projection(1), pair); 1292 Node* new_receiver = NewNode(common()->Projection(1), pair);
1287 1293
1288 // Patch callee and receiver on the environment. 1294 // Patch callee and receiver on the environment.
1289 environment()->Poke(arg_count + 1, new_callee); 1295 environment()->Poke(arg_count + 1, new_callee);
1290 environment()->Poke(arg_count + 0, new_receiver); 1296 environment()->Poke(arg_count + 0, new_receiver);
1291 } 1297 }
1292 1298
1293 // Create node to perform the function call. 1299 // Create node to perform the function call.
1294 const Operator* call = javascript()->Call(args->length() + 2, flags); 1300 const Operator* call = javascript()->CallFunction(args->length() + 2, flags);
1295 Node* value = ProcessArguments(call, args->length() + 2); 1301 Node* value = ProcessArguments(call, args->length() + 2);
1296 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 1302 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
1297 ast_context()->ProduceValue(value); 1303 ast_context()->ProduceValue(value);
1298 } 1304 }
1299 1305
1300 1306
1301 void AstGraphBuilder::VisitCallNew(CallNew* expr) { 1307 void AstGraphBuilder::VisitCallNew(CallNew* expr) {
1302 VisitForValue(expr->expression()); 1308 VisitForValue(expr->expression());
1303 1309
1304 // Evaluate all arguments to the construct call. 1310 // Evaluate all arguments to the construct call.
1305 ZoneList<Expression*>* args = expr->arguments(); 1311 ZoneList<Expression*>* args = expr->arguments();
1306 VisitForValues(args); 1312 VisitForValues(args);
1307 1313
1308 // Create node to perform the construct call. 1314 // Create node to perform the construct call.
1309 const Operator* call = javascript()->CallNew(args->length() + 1); 1315 const Operator* call = javascript()->CallConstruct(args->length() + 1);
1310 Node* value = ProcessArguments(call, args->length() + 1); 1316 Node* value = ProcessArguments(call, args->length() + 1);
1311 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 1317 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
1312 ast_context()->ProduceValue(value); 1318 ast_context()->ProduceValue(value);
1313 } 1319 }
1314 1320
1315 1321
1316 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { 1322 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
1317 Handle<String> name = expr->name(); 1323 Handle<String> name = expr->name();
1318 1324
1319 // The callee and the receiver both have to be pushed onto the operand stack 1325 // The callee and the receiver both have to be pushed onto the operand stack
1320 // before arguments are being evaluated. 1326 // before arguments are being evaluated.
1321 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; 1327 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS;
1322 Node* receiver_value = BuildLoadBuiltinsObject(); 1328 Node* receiver_value = BuildLoadBuiltinsObject();
1323 Unique<String> unique = MakeUnique(name); 1329 Unique<String> unique = MakeUnique(name);
1324 Node* callee_value = NewNode(javascript()->LoadNamed(unique), receiver_value); 1330 Node* callee_value = NewNode(javascript()->LoadNamed(unique), receiver_value);
1325 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft 1331 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft
1326 // refuses to optimize functions with jsruntime calls). 1332 // refuses to optimize functions with jsruntime calls).
1327 PrepareFrameState(callee_value, BailoutId::None(), 1333 PrepareFrameState(callee_value, BailoutId::None(),
1328 OutputFrameStateCombine::Push()); 1334 OutputFrameStateCombine::Push());
1329 environment()->Push(callee_value); 1335 environment()->Push(callee_value);
1330 environment()->Push(receiver_value); 1336 environment()->Push(receiver_value);
1331 1337
1332 // Evaluate all arguments to the JS runtime call. 1338 // Evaluate all arguments to the JS runtime call.
1333 ZoneList<Expression*>* args = expr->arguments(); 1339 ZoneList<Expression*>* args = expr->arguments();
1334 VisitForValues(args); 1340 VisitForValues(args);
1335 1341
1336 // Create node to perform the JS runtime call. 1342 // Create node to perform the JS runtime call.
1337 const Operator* call = javascript()->Call(args->length() + 2, flags); 1343 const Operator* call = javascript()->CallFunction(args->length() + 2, flags);
1338 Node* value = ProcessArguments(call, args->length() + 2); 1344 Node* value = ProcessArguments(call, args->length() + 2);
1339 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 1345 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
1340 ast_context()->ProduceValue(value); 1346 ast_context()->ProduceValue(value);
1341 } 1347 }
1342 1348
1343 1349
1344 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) { 1350 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) {
1345 const Runtime::Function* function = expr->function(); 1351 const Runtime::Function* function = expr->function();
1346 1352
1347 // Handle calls to runtime functions implemented in JavaScript separately as 1353 // Handle calls to runtime functions implemented in JavaScript separately as
1348 // the call follows JavaScript ABI and the callee is statically unknown. 1354 // the call follows JavaScript ABI and the callee is statically unknown.
1349 if (expr->is_jsruntime()) { 1355 if (expr->is_jsruntime()) {
1350 DCHECK(function == NULL && expr->name()->length() > 0); 1356 DCHECK(function == NULL && expr->name()->length() > 0);
1351 return VisitCallJSRuntime(expr); 1357 return VisitCallJSRuntime(expr);
1352 } 1358 }
1353 1359
1354 // Evaluate all arguments to the runtime call. 1360 // Evaluate all arguments to the runtime call.
1355 ZoneList<Expression*>* args = expr->arguments(); 1361 ZoneList<Expression*>* args = expr->arguments();
1356 VisitForValues(args); 1362 VisitForValues(args);
1357 1363
1358 // Create node to perform the runtime call. 1364 // Create node to perform the runtime call.
1359 Runtime::FunctionId functionId = function->function_id; 1365 Runtime::FunctionId functionId = function->function_id;
1360 const Operator* call = javascript()->Runtime(functionId, args->length()); 1366 const Operator* call = javascript()->CallRuntime(functionId, args->length());
1361 Node* value = ProcessArguments(call, args->length()); 1367 Node* value = ProcessArguments(call, args->length());
1362 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 1368 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
1363 ast_context()->ProduceValue(value); 1369 ast_context()->ProduceValue(value);
1364 } 1370 }
1365 1371
1366 1372
1367 void AstGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { 1373 void AstGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) {
1368 switch (expr->op()) { 1374 switch (expr->op()) {
1369 case Token::DELETE: 1375 case Token::DELETE:
1370 return VisitDelete(expr); 1376 return VisitDelete(expr);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 AstVisitor::VisitDeclarations(declarations); 1570 AstVisitor::VisitDeclarations(declarations);
1565 if (globals()->is_empty()) return; 1571 if (globals()->is_empty()) return;
1566 Handle<FixedArray> data = 1572 Handle<FixedArray> data =
1567 isolate()->factory()->NewFixedArray(globals()->length(), TENURED); 1573 isolate()->factory()->NewFixedArray(globals()->length(), TENURED);
1568 for (int i = 0; i < globals()->length(); ++i) data->set(i, *globals()->at(i)); 1574 for (int i = 0; i < globals()->length(); ++i) data->set(i, *globals()->at(i));
1569 int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) | 1575 int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) |
1570 DeclareGlobalsNativeFlag::encode(info()->is_native()) | 1576 DeclareGlobalsNativeFlag::encode(info()->is_native()) |
1571 DeclareGlobalsStrictMode::encode(strict_mode()); 1577 DeclareGlobalsStrictMode::encode(strict_mode());
1572 Node* flags = jsgraph()->Constant(encoded_flags); 1578 Node* flags = jsgraph()->Constant(encoded_flags);
1573 Node* pairs = jsgraph()->Constant(data); 1579 Node* pairs = jsgraph()->Constant(data);
1574 const Operator* op = javascript()->Runtime(Runtime::kDeclareGlobals, 3); 1580 const Operator* op = javascript()->CallRuntime(Runtime::kDeclareGlobals, 3);
1575 NewNode(op, current_context(), pairs, flags); 1581 NewNode(op, current_context(), pairs, flags);
1576 globals()->Rewind(0); 1582 globals()->Rewind(0);
1577 } 1583 }
1578 1584
1579 1585
1580 void AstGraphBuilder::VisitIfNotNull(Statement* stmt) { 1586 void AstGraphBuilder::VisitIfNotNull(Statement* stmt) {
1581 if (stmt == NULL) return; 1587 if (stmt == NULL) return;
1582 Visit(stmt); 1588 Visit(stmt);
1583 } 1589 }
1584 1590
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 environment()->Pop(); 1679 environment()->Pop();
1674 Visit(expr->right()); 1680 Visit(expr->right());
1675 } else if (ast_context()->IsEffect()) { 1681 } else if (ast_context()->IsEffect()) {
1676 environment()->Pop(); 1682 environment()->Pop();
1677 } 1683 }
1678 compare_if.End(); 1684 compare_if.End();
1679 ast_context()->ReplaceValue(); 1685 ast_context()->ReplaceValue();
1680 } 1686 }
1681 1687
1682 1688
1689 StrictMode AstGraphBuilder::strict_mode() const {
1690 return info()->strict_mode();
1691 }
1692
1693
1683 Node* AstGraphBuilder::ProcessArguments(const Operator* op, int arity) { 1694 Node* AstGraphBuilder::ProcessArguments(const Operator* op, int arity) {
1684 DCHECK(environment()->stack_height() >= arity); 1695 DCHECK(environment()->stack_height() >= arity);
1685 Node** all = info()->zone()->NewArray<Node*>(arity); 1696 Node** all = info()->zone()->NewArray<Node*>(arity);
1686 for (int i = arity - 1; i >= 0; --i) { 1697 for (int i = arity - 1; i >= 0; --i) {
1687 all[i] = environment()->Pop(); 1698 all[i] = environment()->Pop();
1688 } 1699 }
1689 Node* value = NewNode(op, arity, all); 1700 Node* value = NewNode(op, arity, all);
1690 return value; 1701 return value;
1691 } 1702 }
1692 1703
(...skipping 24 matching lines...) Expand all
1717 1728
1718 return local_context; 1729 return local_context;
1719 } 1730 }
1720 1731
1721 1732
1722 Node* AstGraphBuilder::BuildArgumentsObject(Variable* arguments) { 1733 Node* AstGraphBuilder::BuildArgumentsObject(Variable* arguments) {
1723 if (arguments == NULL) return NULL; 1734 if (arguments == NULL) return NULL;
1724 1735
1725 // Allocate and initialize a new arguments object. 1736 // Allocate and initialize a new arguments object.
1726 Node* callee = GetFunctionClosure(); 1737 Node* callee = GetFunctionClosure();
1727 const Operator* op = javascript()->Runtime(Runtime::kNewArguments, 1); 1738 const Operator* op = javascript()->CallRuntime(Runtime::kNewArguments, 1);
1728 Node* object = NewNode(op, callee); 1739 Node* object = NewNode(op, callee);
1729 1740
1730 // Assign the object to the arguments variable. 1741 // Assign the object to the arguments variable.
1731 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); 1742 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated());
1732 // This should never lazy deopt, so it is fine to send invalid bailout id. 1743 // This should never lazy deopt, so it is fine to send invalid bailout id.
1733 BuildVariableAssignment(arguments, object, Token::ASSIGN, BailoutId::None()); 1744 BuildVariableAssignment(arguments, object, Token::ASSIGN, BailoutId::None());
1734 1745
1735 return object; 1746 return object;
1736 } 1747 }
1737 1748
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 } 1835 }
1825 return value; 1836 return value;
1826 } 1837 }
1827 case Variable::LOOKUP: { 1838 case Variable::LOOKUP: {
1828 // Dynamic lookup of context variable (anywhere in the chain). 1839 // Dynamic lookup of context variable (anywhere in the chain).
1829 Node* name = jsgraph()->Constant(variable->name()); 1840 Node* name = jsgraph()->Constant(variable->name());
1830 Runtime::FunctionId function_id = 1841 Runtime::FunctionId function_id =
1831 (contextual_mode == CONTEXTUAL) 1842 (contextual_mode == CONTEXTUAL)
1832 ? Runtime::kLoadLookupSlot 1843 ? Runtime::kLoadLookupSlot
1833 : Runtime::kLoadLookupSlotNoReferenceError; 1844 : Runtime::kLoadLookupSlotNoReferenceError;
1834 const Operator* op = javascript()->Runtime(function_id, 2); 1845 const Operator* op = javascript()->CallRuntime(function_id, 2);
1835 Node* pair = NewNode(op, current_context(), name); 1846 Node* pair = NewNode(op, current_context(), name);
1836 PrepareFrameState(pair, bailout_id, OutputFrameStateCombine::Push(1)); 1847 PrepareFrameState(pair, bailout_id, OutputFrameStateCombine::Push(1));
1837 return NewNode(common()->Projection(0), pair); 1848 return NewNode(common()->Projection(0), pair);
1838 } 1849 }
1839 } 1850 }
1840 UNREACHABLE(); 1851 UNREACHABLE();
1841 return NULL; 1852 return NULL;
1842 } 1853 }
1843 1854
1844 1855
(...skipping 12 matching lines...) Expand all
1857 } 1868 }
1858 case Variable::PARAMETER: 1869 case Variable::PARAMETER:
1859 case Variable::LOCAL: 1870 case Variable::LOCAL:
1860 case Variable::CONTEXT: 1871 case Variable::CONTEXT:
1861 // Local var, const, or let variable or context variable. 1872 // Local var, const, or let variable or context variable.
1862 return variable->is_this() ? jsgraph()->TrueConstant() 1873 return variable->is_this() ? jsgraph()->TrueConstant()
1863 : jsgraph()->FalseConstant(); 1874 : jsgraph()->FalseConstant();
1864 case Variable::LOOKUP: { 1875 case Variable::LOOKUP: {
1865 // Dynamic lookup of context variable (anywhere in the chain). 1876 // Dynamic lookup of context variable (anywhere in the chain).
1866 Node* name = jsgraph()->Constant(variable->name()); 1877 Node* name = jsgraph()->Constant(variable->name());
1867 const Operator* op = javascript()->Runtime(Runtime::kDeleteLookupSlot, 2); 1878 const Operator* op =
1879 javascript()->CallRuntime(Runtime::kDeleteLookupSlot, 2);
1868 Node* result = NewNode(op, current_context(), name); 1880 Node* result = NewNode(op, current_context(), name);
1869 PrepareFrameState(result, bailout_id, state_combine); 1881 PrepareFrameState(result, bailout_id, state_combine);
1870 return result; 1882 return result;
1871 } 1883 }
1872 } 1884 }
1873 UNREACHABLE(); 1885 UNREACHABLE();
1874 return NULL; 1886 return NULL;
1875 } 1887 }
1876 1888
1877 1889
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 } 1955 }
1944 const Operator* op = javascript()->StoreContext(depth, variable->index()); 1956 const Operator* op = javascript()->StoreContext(depth, variable->index());
1945 return NewNode(op, current_context(), value); 1957 return NewNode(op, current_context(), value);
1946 } 1958 }
1947 case Variable::LOOKUP: { 1959 case Variable::LOOKUP: {
1948 // Dynamic lookup of context variable (anywhere in the chain). 1960 // Dynamic lookup of context variable (anywhere in the chain).
1949 Node* name = jsgraph()->Constant(variable->name()); 1961 Node* name = jsgraph()->Constant(variable->name());
1950 Node* strict = jsgraph()->Constant(strict_mode()); 1962 Node* strict = jsgraph()->Constant(strict_mode());
1951 // TODO(mstarzinger): Use Runtime::kInitializeLegacyConstLookupSlot for 1963 // TODO(mstarzinger): Use Runtime::kInitializeLegacyConstLookupSlot for
1952 // initializations of const declarations. 1964 // initializations of const declarations.
1953 const Operator* op = javascript()->Runtime(Runtime::kStoreLookupSlot, 4); 1965 const Operator* op =
1966 javascript()->CallRuntime(Runtime::kStoreLookupSlot, 4);
1954 Node* store = NewNode(op, value, current_context(), name, strict); 1967 Node* store = NewNode(op, value, current_context(), name, strict);
1955 PrepareFrameState(store, bailout_id); 1968 PrepareFrameState(store, bailout_id);
1956 return store; 1969 return store;
1957 } 1970 }
1958 } 1971 }
1959 UNREACHABLE(); 1972 UNREACHABLE();
1960 return NULL; 1973 return NULL;
1961 } 1974 }
1962 1975
1963 1976
(...skipping 24 matching lines...) Expand all
1988 Node* AstGraphBuilder::BuildToBoolean(Node* value) { 2001 Node* AstGraphBuilder::BuildToBoolean(Node* value) {
1989 // TODO(mstarzinger): Possible optimization is to NOP for boolean values. 2002 // TODO(mstarzinger): Possible optimization is to NOP for boolean values.
1990 return NewNode(javascript()->ToBoolean(), value); 2003 return NewNode(javascript()->ToBoolean(), value);
1991 } 2004 }
1992 2005
1993 2006
1994 Node* AstGraphBuilder::BuildThrowReferenceError(Variable* variable, 2007 Node* AstGraphBuilder::BuildThrowReferenceError(Variable* variable,
1995 BailoutId bailout_id) { 2008 BailoutId bailout_id) {
1996 // TODO(mstarzinger): Should be unified with the VisitThrow implementation. 2009 // TODO(mstarzinger): Should be unified with the VisitThrow implementation.
1997 Node* variable_name = jsgraph()->Constant(variable->name()); 2010 Node* variable_name = jsgraph()->Constant(variable->name());
1998 const Operator* op = javascript()->Runtime(Runtime::kThrowReferenceError, 1); 2011 const Operator* op =
2012 javascript()->CallRuntime(Runtime::kThrowReferenceError, 1);
1999 Node* call = NewNode(op, variable_name); 2013 Node* call = NewNode(op, variable_name);
2000 PrepareFrameState(call, bailout_id); 2014 PrepareFrameState(call, bailout_id);
2001 return call; 2015 return call;
2002 } 2016 }
2003 2017
2004 2018
2005 Node* AstGraphBuilder::BuildBinaryOp(Node* left, Node* right, Token::Value op) { 2019 Node* AstGraphBuilder::BuildBinaryOp(Node* left, Node* right, Token::Value op) {
2006 const Operator* js_op; 2020 const Operator* js_op;
2007 switch (op) { 2021 switch (op) {
2008 case Token::BIT_OR: 2022 case Token::BIT_OR:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() == 2066 DCHECK(NodeProperties::GetFrameStateInput(node)->opcode() ==
2053 IrOpcode::kDead); 2067 IrOpcode::kDead);
2054 NodeProperties::ReplaceFrameStateInput( 2068 NodeProperties::ReplaceFrameStateInput(
2055 node, environment()->Checkpoint(ast_id, combine)); 2069 node, environment()->Checkpoint(ast_id, combine));
2056 } 2070 }
2057 } 2071 }
2058 2072
2059 } 2073 }
2060 } 2074 }
2061 } // namespace v8::internal::compiler 2075 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/change-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698