OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast-numbering.h" | 10 #include "src/ast-numbering.h" |
(...skipping 11329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11340 if (IsLiteralCompareBool(isolate(), left, op, right)) { | 11340 if (IsLiteralCompareBool(isolate(), left, op, right)) { |
11341 HCompareObjectEqAndBranch* result = | 11341 HCompareObjectEqAndBranch* result = |
11342 New<HCompareObjectEqAndBranch>(left, right); | 11342 New<HCompareObjectEqAndBranch>(left, right); |
11343 return ast_context()->ReturnControl(result, expr->id()); | 11343 return ast_context()->ReturnControl(result, expr->id()); |
11344 } | 11344 } |
11345 | 11345 |
11346 if (op == Token::INSTANCEOF) { | 11346 if (op == Token::INSTANCEOF) { |
11347 // Check to see if the rhs of the instanceof is a known function. | 11347 // Check to see if the rhs of the instanceof is a known function. |
11348 if (right->IsConstant() && | 11348 if (right->IsConstant() && |
11349 HConstant::cast(right)->handle(isolate())->IsJSFunction()) { | 11349 HConstant::cast(right)->handle(isolate())->IsJSFunction()) { |
11350 Handle<Object> function = HConstant::cast(right)->handle(isolate()); | 11350 Handle<JSFunction> constructor = |
11351 Handle<JSFunction> target = Handle<JSFunction>::cast(function); | 11351 Handle<JSFunction>::cast(HConstant::cast(right)->handle(isolate())); |
11352 HInstanceOfKnownGlobal* result = | 11352 if (!constructor->map()->has_non_instance_prototype()) { |
11353 New<HInstanceOfKnownGlobal>(left, target); | 11353 JSFunction::EnsureHasInitialMap(constructor); |
11354 return ast_context()->ReturnInstruction(result, expr->id()); | 11354 DCHECK(constructor->has_initial_map()); |
| 11355 Handle<Map> initial_map(constructor->initial_map(), isolate()); |
| 11356 top_info()->dependencies()->AssumeInitialMapCantChange(initial_map); |
| 11357 HInstruction* prototype = |
| 11358 Add<HConstant>(handle(initial_map->prototype(), isolate())); |
| 11359 HHasInPrototypeChainAndBranch* result = |
| 11360 New<HHasInPrototypeChainAndBranch>(left, prototype); |
| 11361 return ast_context()->ReturnControl(result, expr->id()); |
| 11362 } |
11355 } | 11363 } |
11356 | 11364 |
11357 HInstanceOf* result = New<HInstanceOf>(left, right); | 11365 HInstanceOf* result = New<HInstanceOf>(left, right); |
11358 return ast_context()->ReturnInstruction(result, expr->id()); | 11366 return ast_context()->ReturnInstruction(result, expr->id()); |
11359 | 11367 |
11360 } else if (op == Token::IN) { | 11368 } else if (op == Token::IN) { |
11361 HValue* function = AddLoadJSBuiltin(Builtins::IN); | 11369 HValue* function = AddLoadJSBuiltin(Builtins::IN); |
11362 Add<HPushArguments>(left, right); | 11370 Add<HPushArguments>(left, right); |
11363 // TODO(olivf) InvokeFunction produces a check for the parameter count, | 11371 // TODO(olivf) InvokeFunction produces a check for the parameter count, |
11364 // even though we are certain to pass the correct number of arguments here. | 11372 // even though we are certain to pass the correct number of arguments here. |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12545 DCHECK(call->arguments()->length() == 1); | 12553 DCHECK(call->arguments()->length() == 1); |
12546 Visit(call->arguments()->at(0)); | 12554 Visit(call->arguments()->at(0)); |
12547 } | 12555 } |
12548 | 12556 |
12549 | 12557 |
12550 void HOptimizedGraphBuilder::GenerateUnlikely(CallRuntime* call) { | 12558 void HOptimizedGraphBuilder::GenerateUnlikely(CallRuntime* call) { |
12551 return GenerateLikely(call); | 12559 return GenerateLikely(call); |
12552 } | 12560 } |
12553 | 12561 |
12554 | 12562 |
| 12563 void HOptimizedGraphBuilder::GenerateHasInPrototypeChain(CallRuntime* call) { |
| 12564 DCHECK_EQ(2, call->arguments()->length()); |
| 12565 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
| 12566 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
| 12567 HValue* prototype = Pop(); |
| 12568 HValue* object = Pop(); |
| 12569 HHasInPrototypeChainAndBranch* result = |
| 12570 New<HHasInPrototypeChainAndBranch>(object, prototype); |
| 12571 return ast_context()->ReturnControl(result, call->id()); |
| 12572 } |
| 12573 |
| 12574 |
12555 void HOptimizedGraphBuilder::GenerateFixedArrayGet(CallRuntime* call) { | 12575 void HOptimizedGraphBuilder::GenerateFixedArrayGet(CallRuntime* call) { |
12556 DCHECK(call->arguments()->length() == 2); | 12576 DCHECK(call->arguments()->length() == 2); |
12557 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 12577 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
12558 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); | 12578 CHECK_ALIVE(VisitForValue(call->arguments()->at(1))); |
12559 HValue* index = Pop(); | 12579 HValue* index = Pop(); |
12560 HValue* object = Pop(); | 12580 HValue* object = Pop(); |
12561 HInstruction* result = New<HLoadKeyed>( | 12581 HInstruction* result = New<HLoadKeyed>( |
12562 object, index, nullptr, FAST_HOLEY_ELEMENTS, ALLOW_RETURN_HOLE); | 12582 object, index, nullptr, FAST_HOLEY_ELEMENTS, ALLOW_RETURN_HOLE); |
12563 return ast_context()->ReturnInstruction(result, call->id()); | 12583 return ast_context()->ReturnInstruction(result, call->id()); |
12564 } | 12584 } |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13432 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13452 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13433 } | 13453 } |
13434 | 13454 |
13435 #ifdef DEBUG | 13455 #ifdef DEBUG |
13436 graph_->Verify(false); // No full verify. | 13456 graph_->Verify(false); // No full verify. |
13437 #endif | 13457 #endif |
13438 } | 13458 } |
13439 | 13459 |
13440 } // namespace internal | 13460 } // namespace internal |
13441 } // namespace v8 | 13461 } // namespace v8 |
OLD | NEW |