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/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2335 Node* name = jsgraph()->Constant(variable->name()); | 2335 Node* name = jsgraph()->Constant(variable->name()); |
2336 const Operator* op = | 2336 const Operator* op = |
2337 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2); | 2337 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2); |
2338 Node* pair = NewNode(op, current_context(), name); | 2338 Node* pair = NewNode(op, current_context(), name); |
2339 callee_value = NewNode(common()->Projection(0), pair); | 2339 callee_value = NewNode(common()->Projection(0), pair); |
2340 receiver_value = NewNode(common()->Projection(1), pair); | 2340 receiver_value = NewNode(common()->Projection(1), pair); |
2341 PrepareFrameState(pair, expr->LookupId(), | 2341 PrepareFrameState(pair, expr->LookupId(), |
2342 OutputFrameStateCombine::Push(2)); | 2342 OutputFrameStateCombine::Push(2)); |
2343 break; | 2343 break; |
2344 } | 2344 } |
2345 case Call::PROPERTY_CALL: { | 2345 case Call::NAMED_PROPERTY_CALL: { |
2346 Property* property = callee->AsProperty(); | 2346 Property* property = callee->AsProperty(); |
2347 VectorSlotPair pair = | 2347 VectorSlotPair feedback = |
2348 CreateVectorSlotPair(property->PropertyFeedbackSlot()); | 2348 CreateVectorSlotPair(property->PropertyFeedbackSlot()); |
2349 LhsKind property_type = Property::GetAssignType(property); | 2349 VisitForValue(property->obj()); |
2350 switch (property_type) { | 2350 FrameStateBeforeAndAfter states(this, property->obj()->id()); |
2351 case NAMED_PROPERTY: { | 2351 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); |
2352 VisitForValue(property->obj()); | 2352 Node* object = environment()->Top(); |
2353 FrameStateBeforeAndAfter states(this, property->obj()->id()); | 2353 callee_value = BuildNamedLoad(object, name, feedback); |
2354 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); | 2354 states.AddToNode(callee_value, property->LoadId(), |
2355 Node* object = environment()->Top(); | 2355 OutputFrameStateCombine::Push()); |
2356 callee_value = BuildNamedLoad(object, name, pair); | 2356 // Note that a PROPERTY_CALL requires the receiver to be wrapped into |
2357 states.AddToNode(callee_value, property->LoadId(), | 2357 // an object for sloppy callees. However the receiver is guaranteed |
2358 OutputFrameStateCombine::Push()); | 2358 // not to be null or undefined at this point. |
2359 // Note that a PROPERTY_CALL requires the receiver to be wrapped into | 2359 receiver_hint = ConvertReceiverMode::kNotNullOrUndefined; |
2360 // an object for sloppy callees. However the receiver is guaranteed | 2360 receiver_value = environment()->Pop(); |
2361 // not to be null or undefined at this point. | 2361 flags = CALL_AS_METHOD; |
2362 receiver_hint = ConvertReceiverMode::kNotNullOrUndefined; | 2362 break; |
2363 receiver_value = environment()->Pop(); | 2363 } |
2364 flags = CALL_AS_METHOD; | 2364 case Call::KEYED_PROPERTY_CALL: { |
2365 break; | 2365 Property* property = callee->AsProperty(); |
2366 } | 2366 VectorSlotPair feedback = |
2367 case KEYED_PROPERTY: { | 2367 CreateVectorSlotPair(property->PropertyFeedbackSlot()); |
2368 VisitForValue(property->obj()); | 2368 VisitForValue(property->obj()); |
2369 VisitForValue(property->key()); | 2369 VisitForValue(property->key()); |
2370 FrameStateBeforeAndAfter states(this, property->key()->id()); | 2370 FrameStateBeforeAndAfter states(this, property->key()->id()); |
2371 Node* key = environment()->Pop(); | 2371 Node* key = environment()->Pop(); |
2372 Node* object = environment()->Top(); | 2372 Node* object = environment()->Top(); |
2373 callee_value = BuildKeyedLoad(object, key, pair); | 2373 callee_value = BuildKeyedLoad(object, key, feedback); |
2374 states.AddToNode(callee_value, property->LoadId(), | 2374 states.AddToNode(callee_value, property->LoadId(), |
2375 OutputFrameStateCombine::Push()); | 2375 OutputFrameStateCombine::Push()); |
2376 // Note that a PROPERTY_CALL requires the receiver to be wrapped into | 2376 // Note that a PROPERTY_CALL requires the receiver to be wrapped into |
2377 // an object for sloppy callees. However the receiver is guaranteed | 2377 // an object for sloppy callees. However the receiver is guaranteed |
2378 // not to be null or undefined at this point. | 2378 // not to be null or undefined at this point. |
2379 receiver_hint = ConvertReceiverMode::kNotNullOrUndefined; | 2379 receiver_hint = ConvertReceiverMode::kNotNullOrUndefined; |
2380 receiver_value = environment()->Pop(); | 2380 receiver_value = environment()->Pop(); |
2381 flags = CALL_AS_METHOD; | 2381 flags = CALL_AS_METHOD; |
2382 break; | 2382 break; |
2383 } | 2383 } |
2384 case NAMED_SUPER_PROPERTY: { | 2384 case Call::NAMED_SUPER_PROPERTY_CALL: { |
2385 SuperPropertyReference* super_ref = | 2385 Property* property = callee->AsProperty(); |
2386 property->obj()->AsSuperPropertyReference(); | 2386 SuperPropertyReference* super_ref = |
2387 VisitForValue(super_ref->home_object()); | 2387 property->obj()->AsSuperPropertyReference(); |
2388 VisitForValue(super_ref->this_var()); | 2388 VisitForValue(super_ref->home_object()); |
2389 Node* home = environment()->Peek(1); | 2389 VisitForValue(super_ref->this_var()); |
2390 Node* object = environment()->Top(); | 2390 Node* home = environment()->Peek(1); |
2391 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); | 2391 Node* object = environment()->Top(); |
2392 FrameStateBeforeAndAfter states(this, property->obj()->id()); | 2392 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); |
2393 callee_value = BuildNamedSuperLoad(object, home, name, pair); | 2393 FrameStateBeforeAndAfter states(this, property->obj()->id()); |
2394 states.AddToNode(callee_value, property->LoadId(), | 2394 callee_value = BuildNamedSuperLoad(object, home, name, VectorSlotPair()); |
2395 OutputFrameStateCombine::Push()); | 2395 states.AddToNode(callee_value, property->LoadId(), |
2396 // Note that the receiver is not the target of the property load, so | 2396 OutputFrameStateCombine::Push()); |
2397 // it could very well be null or undefined at this point. | 2397 // Note that the receiver is not the target of the property load, so |
2398 receiver_value = environment()->Pop(); | 2398 // it could very well be null or undefined at this point. |
2399 environment()->Drop(1); | 2399 receiver_value = environment()->Pop(); |
2400 break; | 2400 environment()->Drop(1); |
2401 } | 2401 break; |
2402 case KEYED_SUPER_PROPERTY: { | 2402 } |
2403 SuperPropertyReference* super_ref = | 2403 case Call::KEYED_SUPER_PROPERTY_CALL: { |
2404 property->obj()->AsSuperPropertyReference(); | 2404 Property* property = callee->AsProperty(); |
2405 VisitForValue(super_ref->home_object()); | 2405 SuperPropertyReference* super_ref = |
2406 VisitForValue(super_ref->this_var()); | 2406 property->obj()->AsSuperPropertyReference(); |
2407 environment()->Push(environment()->Top()); // Duplicate this_var. | 2407 VisitForValue(super_ref->home_object()); |
2408 environment()->Push(environment()->Peek(2)); // Duplicate home_obj. | 2408 VisitForValue(super_ref->this_var()); |
2409 VisitForValue(property->key()); | 2409 environment()->Push(environment()->Top()); // Duplicate this_var. |
2410 Node* key = environment()->Pop(); | 2410 environment()->Push(environment()->Peek(2)); // Duplicate home_obj. |
2411 Node* home = environment()->Pop(); | 2411 VisitForValue(property->key()); |
2412 Node* object = environment()->Pop(); | 2412 Node* key = environment()->Pop(); |
2413 FrameStateBeforeAndAfter states(this, property->key()->id()); | 2413 Node* home = environment()->Pop(); |
2414 callee_value = BuildKeyedSuperLoad(object, home, key, pair); | 2414 Node* object = environment()->Pop(); |
2415 states.AddToNode(callee_value, property->LoadId(), | 2415 FrameStateBeforeAndAfter states(this, property->key()->id()); |
2416 OutputFrameStateCombine::Push()); | 2416 callee_value = BuildKeyedSuperLoad(object, home, key, VectorSlotPair()); |
2417 // Note that the receiver is not the target of the property load, so | 2417 states.AddToNode(callee_value, property->LoadId(), |
2418 // it could very well be null or undefined at this point. | 2418 OutputFrameStateCombine::Push()); |
2419 receiver_value = environment()->Pop(); | 2419 // Note that the receiver is not the target of the property load, so |
2420 environment()->Drop(1); | 2420 // it could very well be null or undefined at this point. |
2421 break; | 2421 receiver_value = environment()->Pop(); |
2422 } | 2422 environment()->Drop(1); |
2423 case VARIABLE: | |
2424 UNREACHABLE(); | |
2425 } | |
2426 break; | 2423 break; |
2427 } | 2424 } |
2428 case Call::SUPER_CALL: | 2425 case Call::SUPER_CALL: |
2429 return VisitCallSuper(expr); | 2426 return VisitCallSuper(expr); |
2430 case Call::POSSIBLY_EVAL_CALL: | 2427 case Call::POSSIBLY_EVAL_CALL: |
2431 possibly_eval = true; | 2428 possibly_eval = true; |
2432 if (callee->AsVariableProxy()->var()->IsLookupSlot()) { | 2429 if (callee->AsVariableProxy()->var()->IsLookupSlot()) { |
2433 Variable* variable = callee->AsVariableProxy()->var(); | 2430 Variable* variable = callee->AsVariableProxy()->var(); |
2434 Node* name = jsgraph()->Constant(variable->name()); | 2431 Node* name = jsgraph()->Constant(variable->name()); |
2435 const Operator* op = | 2432 const Operator* op = |
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4252 // Phi does not exist yet, introduce one. | 4249 // Phi does not exist yet, introduce one. |
4253 value = NewPhi(inputs, value, control); | 4250 value = NewPhi(inputs, value, control); |
4254 value->ReplaceInput(inputs - 1, other); | 4251 value->ReplaceInput(inputs - 1, other); |
4255 } | 4252 } |
4256 return value; | 4253 return value; |
4257 } | 4254 } |
4258 | 4255 |
4259 } // namespace compiler | 4256 } // namespace compiler |
4260 } // namespace internal | 4257 } // namespace internal |
4261 } // namespace v8 | 4258 } // namespace v8 |
OLD | NEW |