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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/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/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
(...skipping 11480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11491 HValue* left = Pop(); | 11491 HValue* left = Pop(); |
11492 Token::Value op = expr->op(); | 11492 Token::Value op = expr->op(); |
11493 | 11493 |
11494 if (IsLiteralCompareBool(isolate(), left, op, right)) { | 11494 if (IsLiteralCompareBool(isolate(), left, op, right)) { |
11495 HCompareObjectEqAndBranch* result = | 11495 HCompareObjectEqAndBranch* result = |
11496 New<HCompareObjectEqAndBranch>(left, right); | 11496 New<HCompareObjectEqAndBranch>(left, right); |
11497 return ast_context()->ReturnControl(result, expr->id()); | 11497 return ast_context()->ReturnControl(result, expr->id()); |
11498 } | 11498 } |
11499 | 11499 |
11500 if (op == Token::INSTANCEOF) { | 11500 if (op == Token::INSTANCEOF) { |
| 11501 DCHECK(!FLAG_harmony_instanceof); |
11501 // Check to see if the rhs of the instanceof is a known function. | 11502 // Check to see if the rhs of the instanceof is a known function. |
11502 if (right->IsConstant() && | 11503 if (right->IsConstant() && |
11503 HConstant::cast(right)->handle(isolate())->IsJSFunction()) { | 11504 HConstant::cast(right)->handle(isolate())->IsJSFunction()) { |
11504 Handle<JSFunction> constructor = | 11505 Handle<JSFunction> constructor = |
11505 Handle<JSFunction>::cast(HConstant::cast(right)->handle(isolate())); | 11506 Handle<JSFunction>::cast(HConstant::cast(right)->handle(isolate())); |
11506 if (constructor->IsConstructor() && | 11507 if (constructor->IsConstructor() && |
11507 !constructor->map()->has_non_instance_prototype()) { | 11508 !constructor->map()->has_non_instance_prototype()) { |
11508 JSFunction::EnsureHasInitialMap(constructor); | 11509 JSFunction::EnsureHasInitialMap(constructor); |
11509 DCHECK(constructor->has_initial_map()); | 11510 DCHECK(constructor->has_initial_map()); |
11510 Handle<Map> initial_map(constructor->initial_map(), isolate()); | 11511 Handle<Map> initial_map(constructor->initial_map(), isolate()); |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12611 HValue* number = Pop(); | 12612 HValue* number = Pop(); |
12612 HValue* result = BuildNumberToString(number, Type::Any()); | 12613 HValue* result = BuildNumberToString(number, Type::Any()); |
12613 return ast_context()->ReturnValue(result); | 12614 return ast_context()->ReturnValue(result); |
12614 } | 12615 } |
12615 | 12616 |
12616 | 12617 |
12617 // Fast support for calls. | 12618 // Fast support for calls. |
12618 void HOptimizedGraphBuilder::GenerateCall(CallRuntime* call) { | 12619 void HOptimizedGraphBuilder::GenerateCall(CallRuntime* call) { |
12619 DCHECK_LE(2, call->arguments()->length()); | 12620 DCHECK_LE(2, call->arguments()->length()); |
12620 CHECK_ALIVE(VisitExpressions(call->arguments())); | 12621 CHECK_ALIVE(VisitExpressions(call->arguments())); |
| 12622 |
| 12623 // Try and customize ES6 instanceof here. |
| 12624 // We should at least have the constructor on the expression stack. |
| 12625 if (FLAG_harmony_instanceof && FLAG_harmony_instanceof_opt && |
| 12626 call->arguments()->length() == 3) { |
| 12627 HValue* target = environment()->ExpressionStackAt(2); |
| 12628 if (target->IsConstant()) { |
| 12629 HConstant* constant_function = HConstant::cast(target); |
| 12630 if (constant_function->handle(isolate())->IsJSFunction()) { |
| 12631 Handle<JSFunction> func = |
| 12632 Handle<JSFunction>::cast(constant_function->handle(isolate())); |
| 12633 if (*func == isolate()->native_context()->ordinary_has_instance()) { |
| 12634 // Look at the function, which will be argument 1. |
| 12635 HValue* right = environment()->ExpressionStackAt(1); |
| 12636 if (right->IsConstant() && |
| 12637 HConstant::cast(right)->handle(isolate())->IsJSFunction()) { |
| 12638 Handle<JSFunction> constructor = Handle<JSFunction>::cast( |
| 12639 HConstant::cast(right)->handle(isolate())); |
| 12640 if (constructor->IsConstructor() && |
| 12641 !constructor->map()->has_non_instance_prototype()) { |
| 12642 JSFunction::EnsureHasInitialMap(constructor); |
| 12643 DCHECK(constructor->has_initial_map()); |
| 12644 Handle<Map> initial_map(constructor->initial_map(), isolate()); |
| 12645 top_info()->dependencies()->AssumeInitialMapCantChange( |
| 12646 initial_map); |
| 12647 HInstruction* prototype = |
| 12648 Add<HConstant>(handle(initial_map->prototype(), isolate())); |
| 12649 HValue* left = environment()->ExpressionStackAt(0); |
| 12650 HHasInPrototypeChainAndBranch* result = |
| 12651 New<HHasInPrototypeChainAndBranch>(left, prototype); |
| 12652 Drop(3); |
| 12653 return ast_context()->ReturnControl(result, call->id()); |
| 12654 } |
| 12655 } |
| 12656 } |
| 12657 } |
| 12658 } |
| 12659 } |
| 12660 |
12621 CallTrampolineDescriptor descriptor(isolate()); | 12661 CallTrampolineDescriptor descriptor(isolate()); |
12622 PushArgumentsFromEnvironment(call->arguments()->length() - 1); | 12662 PushArgumentsFromEnvironment(call->arguments()->length() - 1); |
12623 HValue* trampoline = Add<HConstant>(isolate()->builtins()->Call()); | 12663 HValue* trampoline = Add<HConstant>(isolate()->builtins()->Call()); |
12624 HValue* target = Pop(); | 12664 HValue* target = Pop(); |
12625 HValue* values[] = {context(), target, | 12665 HValue* values[] = {context(), target, |
12626 Add<HConstant>(call->arguments()->length() - 2)}; | 12666 Add<HConstant>(call->arguments()->length() - 2)}; |
12627 HInstruction* result = New<HCallWithDescriptor>( | 12667 HInstruction* result = New<HCallWithDescriptor>( |
12628 trampoline, call->arguments()->length() - 1, descriptor, | 12668 trampoline, call->arguments()->length() - 1, descriptor, |
12629 Vector<HValue*>(values, arraysize(values))); | 12669 Vector<HValue*>(values, arraysize(values))); |
12630 return ast_context()->ReturnInstruction(result, call->id()); | 12670 return ast_context()->ReturnInstruction(result, call->id()); |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13525 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13565 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13526 } | 13566 } |
13527 | 13567 |
13528 #ifdef DEBUG | 13568 #ifdef DEBUG |
13529 graph_->Verify(false); // No full verify. | 13569 graph_->Verify(false); // No full verify. |
13530 #endif | 13570 #endif |
13531 } | 13571 } |
13532 | 13572 |
13533 } // namespace internal | 13573 } // namespace internal |
13534 } // namespace v8 | 13574 } // namespace v8 |
OLD | NEW |