| 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/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
| 10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
| (...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 // during evaluation of the method values. | 890 // during evaluation of the method values. |
| 891 environment()->Push(literal); | 891 environment()->Push(literal); |
| 892 environment()->Push(proto); | 892 environment()->Push(proto); |
| 893 | 893 |
| 894 // Create nodes to store method values into the literal. | 894 // Create nodes to store method values into the literal. |
| 895 for (int i = 0; i < expr->properties()->length(); i++) { | 895 for (int i = 0; i < expr->properties()->length(); i++) { |
| 896 ObjectLiteral::Property* property = expr->properties()->at(i); | 896 ObjectLiteral::Property* property = expr->properties()->at(i); |
| 897 environment()->Push(property->is_static() ? literal : proto); | 897 environment()->Push(property->is_static() ? literal : proto); |
| 898 | 898 |
| 899 VisitForValue(property->key()); | 899 VisitForValue(property->key()); |
| 900 environment()->Push(BuildToName(environment()->Pop())); |
| 900 VisitForValue(property->value()); | 901 VisitForValue(property->value()); |
| 901 Node* value = environment()->Pop(); | 902 Node* value = environment()->Pop(); |
| 902 Node* key = environment()->Pop(); | 903 Node* key = environment()->Pop(); |
| 903 Node* receiver = environment()->Pop(); | 904 Node* receiver = environment()->Pop(); |
| 904 switch (property->kind()) { | 905 switch (property->kind()) { |
| 905 case ObjectLiteral::Property::CONSTANT: | 906 case ObjectLiteral::Property::CONSTANT: |
| 906 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 907 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 907 UNREACHABLE(); | 908 UNREACHABLE(); |
| 908 case ObjectLiteral::Property::COMPUTED: | 909 case ObjectLiteral::Property::COMPUTED: |
| 909 case ObjectLiteral::Property::PROTOTYPE: { | 910 case ObjectLiteral::Property::PROTOTYPE: { |
| (...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2225 | 2226 |
| 2226 Node* AstGraphBuilder::BuildLoadGlobalProxy() { | 2227 Node* AstGraphBuilder::BuildLoadGlobalProxy() { |
| 2227 Node* global = BuildLoadGlobalObject(); | 2228 Node* global = BuildLoadGlobalObject(); |
| 2228 Node* proxy = | 2229 Node* proxy = |
| 2229 BuildLoadObjectField(global, JSGlobalObject::kGlobalProxyOffset); | 2230 BuildLoadObjectField(global, JSGlobalObject::kGlobalProxyOffset); |
| 2230 return proxy; | 2231 return proxy; |
| 2231 } | 2232 } |
| 2232 | 2233 |
| 2233 | 2234 |
| 2234 Node* AstGraphBuilder::BuildToBoolean(Node* input) { | 2235 Node* AstGraphBuilder::BuildToBoolean(Node* input) { |
| 2235 // TODO(titzer): this should be in a JSOperatorReducer. | 2236 // TODO(titzer): This should be in a JSOperatorReducer. |
| 2236 switch (input->opcode()) { | 2237 switch (input->opcode()) { |
| 2237 case IrOpcode::kInt32Constant: | 2238 case IrOpcode::kInt32Constant: |
| 2238 return jsgraph_->BooleanConstant(!Int32Matcher(input).Is(0)); | 2239 return jsgraph_->BooleanConstant(!Int32Matcher(input).Is(0)); |
| 2239 case IrOpcode::kFloat64Constant: | 2240 case IrOpcode::kFloat64Constant: |
| 2240 return jsgraph_->BooleanConstant(!Float64Matcher(input).Is(0)); | 2241 return jsgraph_->BooleanConstant(!Float64Matcher(input).Is(0)); |
| 2241 case IrOpcode::kNumberConstant: | 2242 case IrOpcode::kNumberConstant: |
| 2242 return jsgraph_->BooleanConstant(!NumberMatcher(input).Is(0)); | 2243 return jsgraph_->BooleanConstant(!NumberMatcher(input).Is(0)); |
| 2243 case IrOpcode::kHeapConstant: { | 2244 case IrOpcode::kHeapConstant: { |
| 2244 Handle<Object> object = HeapObjectMatcher<Object>(input).Value().handle(); | 2245 Handle<Object> object = HeapObjectMatcher<Object>(input).Value().handle(); |
| 2245 return jsgraph_->BooleanConstant(object->BooleanValue()); | 2246 return jsgraph_->BooleanConstant(object->BooleanValue()); |
| 2246 } | 2247 } |
| 2247 default: | 2248 default: |
| 2248 break; | 2249 break; |
| 2249 } | 2250 } |
| 2250 if (NodeProperties::IsTyped(input)) { | 2251 if (NodeProperties::IsTyped(input)) { |
| 2251 Type* upper = NodeProperties::GetBounds(input).upper; | 2252 Type* upper = NodeProperties::GetBounds(input).upper; |
| 2252 if (upper->Is(Type::Boolean())) return input; | 2253 if (upper->Is(Type::Boolean())) return input; |
| 2253 } | 2254 } |
| 2254 | 2255 |
| 2255 return NewNode(javascript()->ToBoolean(), input); | 2256 return NewNode(javascript()->ToBoolean(), input); |
| 2256 } | 2257 } |
| 2257 | 2258 |
| 2258 | 2259 |
| 2260 Node* AstGraphBuilder::BuildToName(Node* input) { |
| 2261 // TODO(turbofan): Possible optimization is to NOP on name constants. But the |
| 2262 // same caveat as with BuildToBoolean applies, and it should be factored out |
| 2263 // into a JSOperatorReducer. |
| 2264 return NewNode(javascript()->ToName(), input); |
| 2265 } |
| 2266 |
| 2267 |
| 2259 Node* AstGraphBuilder::BuildThrowReferenceError(Variable* variable, | 2268 Node* AstGraphBuilder::BuildThrowReferenceError(Variable* variable, |
| 2260 BailoutId bailout_id) { | 2269 BailoutId bailout_id) { |
| 2261 // TODO(mstarzinger): Should be unified with the VisitThrow implementation. | 2270 // TODO(mstarzinger): Should be unified with the VisitThrow implementation. |
| 2262 Node* variable_name = jsgraph()->Constant(variable->name()); | 2271 Node* variable_name = jsgraph()->Constant(variable->name()); |
| 2263 const Operator* op = | 2272 const Operator* op = |
| 2264 javascript()->CallRuntime(Runtime::kThrowReferenceError, 1); | 2273 javascript()->CallRuntime(Runtime::kThrowReferenceError, 1); |
| 2265 Node* call = NewNode(op, variable_name); | 2274 Node* call = NewNode(op, variable_name); |
| 2266 PrepareFrameState(call, bailout_id); | 2275 PrepareFrameState(call, bailout_id); |
| 2267 return call; | 2276 return call; |
| 2268 } | 2277 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2358 | 2367 |
| 2359 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( | 2368 BitVector* AstGraphBuilder::GetVariablesAssignedInLoop( |
| 2360 IterationStatement* stmt) { | 2369 IterationStatement* stmt) { |
| 2361 if (loop_assignment_analysis_ == NULL) return NULL; | 2370 if (loop_assignment_analysis_ == NULL) return NULL; |
| 2362 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); | 2371 return loop_assignment_analysis_->GetVariablesAssignedInLoop(stmt); |
| 2363 } | 2372 } |
| 2364 | 2373 |
| 2365 } // namespace compiler | 2374 } // namespace compiler |
| 2366 } // namespace internal | 2375 } // namespace internal |
| 2367 } // namespace v8 | 2376 } // namespace v8 |
| OLD | NEW |