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/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler/bytecode-branch-analysis.h" | 10 #include "src/compiler/bytecode-branch-analysis.h" |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 | 882 |
883 void BytecodeGraphBuilder::VisitLdaLookupSlot() { | 883 void BytecodeGraphBuilder::VisitLdaLookupSlot() { |
884 BuildLdaLookupSlot(TypeofMode::NOT_INSIDE_TYPEOF); | 884 BuildLdaLookupSlot(TypeofMode::NOT_INSIDE_TYPEOF); |
885 } | 885 } |
886 | 886 |
887 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeof() { | 887 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeof() { |
888 BuildLdaLookupSlot(TypeofMode::INSIDE_TYPEOF); | 888 BuildLdaLookupSlot(TypeofMode::INSIDE_TYPEOF); |
889 } | 889 } |
890 | 890 |
891 void BytecodeGraphBuilder::BuildLdaLookupContextSlot(TypeofMode typeof_mode) { | 891 void BytecodeGraphBuilder::BuildLdaLookupContextSlot(TypeofMode typeof_mode) { |
892 // TODO(leszeks): Build the fast path here. | 892 uint32_t depth = bytecode_iterator().GetUnsignedImmediateOperand(2); |
893 | |
894 // Check if any context in the depth has an extension. | |
895 Environment* slow_environment = nullptr; | |
896 | |
897 for (uint32_t d = 0; d < depth; d++) { | |
Michael Starzinger
2016/09/28 13:55:21
Shouldn't this be "<=" here? IIUC we also want to
| |
898 Node* extension_slot = | |
899 NewNode(javascript()->LoadContext(d, Context::EXTENSION_INDEX, false), | |
900 environment()->Context()); | |
901 | |
902 Node* check_no_extension = | |
903 NewNode(javascript()->StrictEqual(CompareOperationHint::kAny), | |
904 extension_slot, jsgraph()->TheHoleConstant()); | |
905 | |
906 NewBranch(check_no_extension); | |
907 Environment* false_environment = environment(); | |
908 Environment* true_environment = environment()->CopyForConditional(); | |
909 | |
910 { | |
911 set_environment(false_environment); | |
912 NewIfFalse(); | |
913 // If there is an extension, merge into the slow path. | |
914 if (slow_environment == nullptr) { | |
915 slow_environment = false_environment; | |
916 NewMerge(); | |
917 } else { | |
918 slow_environment->Merge(false_environment); | |
919 } | |
920 } | |
921 | |
922 { | |
923 set_environment(true_environment); | |
924 NewIfTrue(); | |
925 // Do nothing on if there is no extension, eventually falling through to | |
926 // the fast path. | |
927 } | |
928 } | |
929 | |
930 // Fast path, do a context load. | |
931 { | |
932 uint32_t slot_index = bytecode_iterator().GetIndexOperand(1); | |
933 | |
934 const Operator* op = javascript()->LoadContext(depth, slot_index, false); | |
935 Node* context = environment()->Context(); | |
936 environment()->BindAccumulator(NewNode(op, context)); | |
937 NewMerge(); | |
938 } | |
939 Environment* fast_environment = environment(); | |
893 | 940 |
894 // Slow path, do a runtime load lookup. | 941 // Slow path, do a runtime load lookup. |
942 set_environment(slow_environment); | |
895 { | 943 { |
896 FrameStateBeforeAndAfter states(this); | 944 FrameStateBeforeAndAfter states(this); |
897 | 945 |
898 Node* name = | 946 Node* name = |
899 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); | 947 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
900 | 948 |
901 const Operator* op = | 949 const Operator* op = |
902 javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF | 950 javascript()->CallRuntime(typeof_mode == TypeofMode::NOT_INSIDE_TYPEOF |
903 ? Runtime::kLoadLookupSlot | 951 ? Runtime::kLoadLookupSlot |
904 : Runtime::kLoadLookupSlotInsideTypeof); | 952 : Runtime::kLoadLookupSlotInsideTypeof); |
905 Node* value = NewNode(op, name); | 953 Node* value = NewNode(op, name); |
906 environment()->BindAccumulator(value, &states); | 954 environment()->BindAccumulator(value, &states); |
907 } | 955 } |
956 | |
957 fast_environment->Merge(slow_environment); | |
958 set_environment(fast_environment); | |
908 } | 959 } |
909 | 960 |
910 void BytecodeGraphBuilder::VisitLdaLookupContextSlot() { | 961 void BytecodeGraphBuilder::VisitLdaLookupContextSlot() { |
911 BuildLdaLookupContextSlot(TypeofMode::NOT_INSIDE_TYPEOF); | 962 BuildLdaLookupContextSlot(TypeofMode::NOT_INSIDE_TYPEOF); |
912 } | 963 } |
913 | 964 |
914 void BytecodeGraphBuilder::VisitLdaLookupContextSlotInsideTypeof() { | 965 void BytecodeGraphBuilder::VisitLdaLookupContextSlotInsideTypeof() { |
915 BuildLdaLookupContextSlot(TypeofMode::INSIDE_TYPEOF); | 966 BuildLdaLookupContextSlot(TypeofMode::INSIDE_TYPEOF); |
916 } | 967 } |
917 | 968 |
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2138 // Phi does not exist yet, introduce one. | 2189 // Phi does not exist yet, introduce one. |
2139 value = NewPhi(inputs, value, control); | 2190 value = NewPhi(inputs, value, control); |
2140 value->ReplaceInput(inputs - 1, other); | 2191 value->ReplaceInput(inputs - 1, other); |
2141 } | 2192 } |
2142 return value; | 2193 return value; |
2143 } | 2194 } |
2144 | 2195 |
2145 } // namespace compiler | 2196 } // namespace compiler |
2146 } // namespace internal | 2197 } // namespace internal |
2147 } // namespace v8 | 2198 } // namespace v8 |
OLD | NEW |