| OLD | NEW |
| 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 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 } | 834 } |
| 835 | 835 |
| 836 | 836 |
| 837 void AstGraphBuilder::VisitLiteral(Literal* expr) { | 837 void AstGraphBuilder::VisitLiteral(Literal* expr) { |
| 838 Node* value = jsgraph()->Constant(expr->value()); | 838 Node* value = jsgraph()->Constant(expr->value()); |
| 839 ast_context()->ProduceValue(value); | 839 ast_context()->ProduceValue(value); |
| 840 } | 840 } |
| 841 | 841 |
| 842 | 842 |
| 843 void AstGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { | 843 void AstGraphBuilder::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 844 Node* closure = GetFunctionClosure(); | 844 Handle<JSFunction> closure = info()->closure(); |
| 845 | 845 |
| 846 // Create node to materialize a regular expression literal. | 846 // Create node to materialize a regular expression literal. |
| 847 Node* literals_array = | 847 Node* literals_array = jsgraph()->Constant(handle(closure->literals())); |
| 848 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); | |
| 849 Node* literal_index = jsgraph()->Constant(expr->literal_index()); | 848 Node* literal_index = jsgraph()->Constant(expr->literal_index()); |
| 850 Node* pattern = jsgraph()->Constant(expr->pattern()); | 849 Node* pattern = jsgraph()->Constant(expr->pattern()); |
| 851 Node* flags = jsgraph()->Constant(expr->flags()); | 850 Node* flags = jsgraph()->Constant(expr->flags()); |
| 852 Operator* op = javascript()->Runtime(Runtime::kMaterializeRegExpLiteral, 4); | 851 Operator* op = javascript()->Runtime(Runtime::kMaterializeRegExpLiteral, 4); |
| 853 Node* literal = NewNode(op, literals_array, literal_index, pattern, flags); | 852 Node* literal = NewNode(op, literals_array, literal_index, pattern, flags); |
| 854 ast_context()->ProduceValue(literal); | 853 ast_context()->ProduceValue(literal); |
| 855 } | 854 } |
| 856 | 855 |
| 857 | 856 |
| 858 void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { | 857 void AstGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { |
| 859 Node* closure = GetFunctionClosure(); | 858 Handle<JSFunction> closure = info()->closure(); |
| 860 | 859 |
| 861 // Create node to deep-copy the literal boilerplate. | 860 // Create node to deep-copy the literal boilerplate. |
| 862 expr->BuildConstantProperties(isolate()); | 861 expr->BuildConstantProperties(isolate()); |
| 863 Node* literals_array = | 862 Node* literals_array = jsgraph()->Constant(handle(closure->literals())); |
| 864 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); | |
| 865 Node* literal_index = jsgraph()->Constant(expr->literal_index()); | 863 Node* literal_index = jsgraph()->Constant(expr->literal_index()); |
| 866 Node* constants = jsgraph()->Constant(expr->constant_properties()); | 864 Node* constants = jsgraph()->Constant(expr->constant_properties()); |
| 867 Node* flags = jsgraph()->Constant(expr->ComputeFlags()); | 865 Node* flags = jsgraph()->Constant(expr->ComputeFlags()); |
| 868 Operator* op = javascript()->Runtime(Runtime::kCreateObjectLiteral, 4); | 866 Operator* op = javascript()->Runtime(Runtime::kCreateObjectLiteral, 4); |
| 869 Node* literal = NewNode(op, literals_array, literal_index, constants, flags); | 867 Node* literal = NewNode(op, literals_array, literal_index, constants, flags); |
| 870 | 868 |
| 871 // The object is expected on the operand stack during computation of the | 869 // The object is expected on the operand stack during computation of the |
| 872 // property values and is the value of the entire expression. | 870 // property values and is the value of the entire expression. |
| 873 environment()->Push(literal); | 871 environment()->Push(literal); |
| 874 | 872 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 if (expr->has_function()) { | 957 if (expr->has_function()) { |
| 960 Operator* op = javascript()->Runtime(Runtime::kToFastProperties, 1); | 958 Operator* op = javascript()->Runtime(Runtime::kToFastProperties, 1); |
| 961 NewNode(op, literal); | 959 NewNode(op, literal); |
| 962 } | 960 } |
| 963 | 961 |
| 964 ast_context()->ProduceValue(environment()->Pop()); | 962 ast_context()->ProduceValue(environment()->Pop()); |
| 965 } | 963 } |
| 966 | 964 |
| 967 | 965 |
| 968 void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { | 966 void AstGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
| 969 Node* closure = GetFunctionClosure(); | 967 Handle<JSFunction> closure = info()->closure(); |
| 970 | 968 |
| 971 // Create node to deep-copy the literal boilerplate. | 969 // Create node to deep-copy the literal boilerplate. |
| 972 expr->BuildConstantElements(isolate()); | 970 expr->BuildConstantElements(isolate()); |
| 973 Node* literals_array = | 971 Node* literals_array = jsgraph()->Constant(handle(closure->literals())); |
| 974 BuildLoadObjectField(closure, JSFunction::kLiteralsOffset); | |
| 975 Node* literal_index = jsgraph()->Constant(expr->literal_index()); | 972 Node* literal_index = jsgraph()->Constant(expr->literal_index()); |
| 976 Node* constants = jsgraph()->Constant(expr->constant_elements()); | 973 Node* constants = jsgraph()->Constant(expr->constant_elements()); |
| 977 Node* flags = jsgraph()->Constant(expr->ComputeFlags()); | 974 Node* flags = jsgraph()->Constant(expr->ComputeFlags()); |
| 978 Operator* op = javascript()->Runtime(Runtime::kCreateArrayLiteral, 4); | 975 Operator* op = javascript()->Runtime(Runtime::kCreateArrayLiteral, 4); |
| 979 Node* literal = NewNode(op, literals_array, literal_index, constants, flags); | 976 Node* literal = NewNode(op, literals_array, literal_index, constants, flags); |
| 980 | 977 |
| 981 // The array and the literal index are both expected on the operand stack | 978 // The array and the literal index are both expected on the operand stack |
| 982 // during computation of the element values. | 979 // during computation of the element values. |
| 983 environment()->Push(literal); | 980 environment()->Push(literal); |
| 984 environment()->Push(literal_index); | 981 environment()->Push(literal_index); |
| (...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2031 | 2028 |
| 2032 // Continue with the original environment. | 2029 // Continue with the original environment. |
| 2033 set_environment(continuation_env); | 2030 set_environment(continuation_env); |
| 2034 NewNode(common()->Continuation()); | 2031 NewNode(common()->Continuation()); |
| 2035 } | 2032 } |
| 2036 } | 2033 } |
| 2037 | 2034 |
| 2038 } | 2035 } |
| 2039 } | 2036 } |
| 2040 } // namespace v8::internal::compiler | 2037 } // namespace v8::internal::compiler |
| OLD | NEW |