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/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 } | 1290 } |
1291 | 1291 |
1292 | 1292 |
1293 HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) { | 1293 HValue* HGraphBuilder::BuildWrapReceiver(HValue* object, HValue* function) { |
1294 if (object->type().IsJSObject()) return object; | 1294 if (object->type().IsJSObject()) return object; |
1295 if (function->IsConstant() && | 1295 if (function->IsConstant() && |
1296 HConstant::cast(function)->handle(isolate())->IsJSFunction()) { | 1296 HConstant::cast(function)->handle(isolate())->IsJSFunction()) { |
1297 Handle<JSFunction> f = Handle<JSFunction>::cast( | 1297 Handle<JSFunction> f = Handle<JSFunction>::cast( |
1298 HConstant::cast(function)->handle(isolate())); | 1298 HConstant::cast(function)->handle(isolate())); |
1299 SharedFunctionInfo* shared = f->shared(); | 1299 SharedFunctionInfo* shared = f->shared(); |
1300 if (shared->strict_mode() == STRICT || shared->native()) return object; | 1300 if (is_strict(shared->language_mode()) || shared->native()) return object; |
1301 } | 1301 } |
1302 return Add<HWrapReceiver>(object, function); | 1302 return Add<HWrapReceiver>(object, function); |
1303 } | 1303 } |
1304 | 1304 |
1305 | 1305 |
1306 HValue* HGraphBuilder::BuildCheckForCapacityGrow( | 1306 HValue* HGraphBuilder::BuildCheckForCapacityGrow( |
1307 HValue* object, | 1307 HValue* object, |
1308 HValue* elements, | 1308 HValue* elements, |
1309 ElementsKind kind, | 1309 ElementsKind kind, |
1310 HValue* length, | 1310 HValue* length, |
(...skipping 4887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6198 Handle<Map> HOptimizedGraphBuilder::PropertyAccessInfo::map() { | 6198 Handle<Map> HOptimizedGraphBuilder::PropertyAccessInfo::map() { |
6199 JSFunction* ctor = IC::GetRootConstructor( | 6199 JSFunction* ctor = IC::GetRootConstructor( |
6200 type_, current_info()->closure()->context()->native_context()); | 6200 type_, current_info()->closure()->context()->native_context()); |
6201 if (ctor != NULL) return handle(ctor->initial_map()); | 6201 if (ctor != NULL) return handle(ctor->initial_map()); |
6202 return type_->AsClass()->Map(); | 6202 return type_->AsClass()->Map(); |
6203 } | 6203 } |
6204 | 6204 |
6205 | 6205 |
6206 static bool NeedsWrappingFor(Type* type, Handle<JSFunction> target) { | 6206 static bool NeedsWrappingFor(Type* type, Handle<JSFunction> target) { |
6207 return type->Is(Type::NumberOrString()) && | 6207 return type->Is(Type::NumberOrString()) && |
6208 target->shared()->strict_mode() == SLOPPY && | 6208 is_sloppy(target->shared()->language_mode()) && |
6209 !target->shared()->native(); | 6209 !target->shared()->native(); |
6210 } | 6210 } |
6211 | 6211 |
6212 | 6212 |
6213 HInstruction* HOptimizedGraphBuilder::BuildMonomorphicAccess( | 6213 HInstruction* HOptimizedGraphBuilder::BuildMonomorphicAccess( |
6214 PropertyAccessInfo* info, | 6214 PropertyAccessInfo* info, |
6215 HValue* object, | 6215 HValue* object, |
6216 HValue* checked_object, | 6216 HValue* checked_object, |
6217 HValue* value, | 6217 HValue* value, |
6218 BailoutId ast_id, | 6218 BailoutId ast_id, |
6219 BailoutId return_id, | 6219 BailoutId return_id, |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6575 } | 6575 } |
6576 HInstruction* instr = | 6576 HInstruction* instr = |
6577 Add<HStoreGlobalCell>(value, cell, it.property_details()); | 6577 Add<HStoreGlobalCell>(value, cell, it.property_details()); |
6578 if (instr->HasObservableSideEffects()) { | 6578 if (instr->HasObservableSideEffects()) { |
6579 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 6579 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
6580 } | 6580 } |
6581 } else { | 6581 } else { |
6582 HValue* global_object = Add<HLoadNamedField>( | 6582 HValue* global_object = Add<HLoadNamedField>( |
6583 context(), nullptr, | 6583 context(), nullptr, |
6584 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 6584 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
6585 HStoreNamedGeneric* instr = | 6585 HStoreNamedGeneric* instr = Add<HStoreNamedGeneric>( |
6586 Add<HStoreNamedGeneric>(global_object, var->name(), | 6586 global_object, var->name(), value, function_language_mode()); |
6587 value, function_strict_mode()); | |
6588 USE(instr); | 6587 USE(instr); |
6589 DCHECK(instr->HasObservableSideEffects()); | 6588 DCHECK(instr->HasObservableSideEffects()); |
6590 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 6589 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
6591 } | 6590 } |
6592 } | 6591 } |
6593 | 6592 |
6594 | 6593 |
6595 void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { | 6594 void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { |
6596 Expression* target = expr->target(); | 6595 Expression* target = expr->target(); |
6597 VariableProxy* proxy = target->AsVariableProxy(); | 6596 VariableProxy* proxy = target->AsVariableProxy(); |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6897 if (FLAG_vector_ics) { | 6896 if (FLAG_vector_ics) { |
6898 Handle<SharedFunctionInfo> current_shared = | 6897 Handle<SharedFunctionInfo> current_shared = |
6899 function_state()->compilation_info()->shared_info(); | 6898 function_state()->compilation_info()->shared_info(); |
6900 Handle<TypeFeedbackVector> vector = | 6899 Handle<TypeFeedbackVector> vector = |
6901 handle(current_shared->feedback_vector(), isolate()); | 6900 handle(current_shared->feedback_vector(), isolate()); |
6902 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot(); | 6901 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot(); |
6903 result->SetVectorAndSlot(vector, slot); | 6902 result->SetVectorAndSlot(vector, slot); |
6904 } | 6903 } |
6905 return result; | 6904 return result; |
6906 } else { | 6905 } else { |
6907 return New<HStoreNamedGeneric>(object, name, value, function_strict_mode()); | 6906 return New<HStoreNamedGeneric>(object, name, value, |
| 6907 function_language_mode()); |
6908 } | 6908 } |
6909 } | 6909 } |
6910 | 6910 |
6911 | 6911 |
6912 | 6912 |
6913 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( | 6913 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( |
6914 PropertyAccessType access_type, | 6914 PropertyAccessType access_type, |
6915 Expression* expr, | 6915 Expression* expr, |
6916 HValue* object, | 6916 HValue* object, |
6917 HValue* key, | 6917 HValue* key, |
6918 HValue* value) { | 6918 HValue* value) { |
6919 if (access_type == LOAD) { | 6919 if (access_type == LOAD) { |
6920 HLoadKeyedGeneric* result = New<HLoadKeyedGeneric>(object, key); | 6920 HLoadKeyedGeneric* result = New<HLoadKeyedGeneric>(object, key); |
6921 if (FLAG_vector_ics) { | 6921 if (FLAG_vector_ics) { |
6922 Handle<SharedFunctionInfo> current_shared = | 6922 Handle<SharedFunctionInfo> current_shared = |
6923 function_state()->compilation_info()->shared_info(); | 6923 function_state()->compilation_info()->shared_info(); |
6924 Handle<TypeFeedbackVector> vector = | 6924 Handle<TypeFeedbackVector> vector = |
6925 handle(current_shared->feedback_vector(), isolate()); | 6925 handle(current_shared->feedback_vector(), isolate()); |
6926 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot(); | 6926 FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot(); |
6927 result->SetVectorAndSlot(vector, slot); | 6927 result->SetVectorAndSlot(vector, slot); |
6928 } | 6928 } |
6929 return result; | 6929 return result; |
6930 } else { | 6930 } else { |
6931 return New<HStoreKeyedGeneric>(object, key, value, function_strict_mode()); | 6931 return New<HStoreKeyedGeneric>(object, key, value, |
| 6932 function_language_mode()); |
6932 } | 6933 } |
6933 } | 6934 } |
6934 | 6935 |
6935 | 6936 |
6936 LoadKeyedHoleMode HOptimizedGraphBuilder::BuildKeyedHoleMode(Handle<Map> map) { | 6937 LoadKeyedHoleMode HOptimizedGraphBuilder::BuildKeyedHoleMode(Handle<Map> map) { |
6937 // Loads from a "stock" fast holey double arrays can elide the hole check. | 6938 // Loads from a "stock" fast holey double arrays can elide the hole check. |
6938 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; | 6939 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; |
6939 if (*map == isolate()->get_initial_js_array_map(FAST_HOLEY_DOUBLE_ELEMENTS) && | 6940 if (*map == isolate()->get_initial_js_array_map(FAST_HOLEY_DOUBLE_ELEMENTS) && |
6940 isolate()->IsFastArrayConstructorPrototypeChainIntact()) { | 6941 isolate()->IsFastArrayConstructorPrototypeChainIntact()) { |
6941 Handle<JSObject> prototype(JSObject::cast(map->prototype()), isolate()); | 6942 Handle<JSObject> prototype(JSObject::cast(map->prototype()), isolate()); |
(...skipping 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8933 int call_index = args_length + 1; | 8934 int call_index = args_length + 1; |
8934 environment()->RemoveExpressionStackAt(call_index); | 8935 environment()->RemoveExpressionStackAt(call_index); |
8935 | 8936 |
8936 HandleIndirectCall(expr, function, args_length); | 8937 HandleIndirectCall(expr, function, args_length); |
8937 } | 8938 } |
8938 | 8939 |
8939 | 8940 |
8940 HValue* HOptimizedGraphBuilder::ImplicitReceiverFor(HValue* function, | 8941 HValue* HOptimizedGraphBuilder::ImplicitReceiverFor(HValue* function, |
8941 Handle<JSFunction> target) { | 8942 Handle<JSFunction> target) { |
8942 SharedFunctionInfo* shared = target->shared(); | 8943 SharedFunctionInfo* shared = target->shared(); |
8943 if (shared->strict_mode() == SLOPPY && !shared->native()) { | 8944 if (is_sloppy(shared->language_mode()) && !shared->native()) { |
8944 // Cannot embed a direct reference to the global proxy | 8945 // Cannot embed a direct reference to the global proxy |
8945 // as is it dropped on deserialization. | 8946 // as is it dropped on deserialization. |
8946 CHECK(!isolate()->serializer_enabled()); | 8947 CHECK(!isolate()->serializer_enabled()); |
8947 Handle<JSObject> global_proxy(target->context()->global_proxy()); | 8948 Handle<JSObject> global_proxy(target->context()->global_proxy()); |
8948 return Add<HConstant>(global_proxy); | 8949 return Add<HConstant>(global_proxy); |
8949 } | 8950 } |
8950 return graph()->GetConstantUndefined(); | 8951 return graph()->GetConstantUndefined(); |
8951 } | 8952 } |
8952 | 8953 |
8953 | 8954 |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10021 | 10022 |
10022 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { | 10023 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { |
10023 Property* prop = expr->expression()->AsProperty(); | 10024 Property* prop = expr->expression()->AsProperty(); |
10024 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 10025 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
10025 if (prop != NULL) { | 10026 if (prop != NULL) { |
10026 CHECK_ALIVE(VisitForValue(prop->obj())); | 10027 CHECK_ALIVE(VisitForValue(prop->obj())); |
10027 CHECK_ALIVE(VisitForValue(prop->key())); | 10028 CHECK_ALIVE(VisitForValue(prop->key())); |
10028 HValue* key = Pop(); | 10029 HValue* key = Pop(); |
10029 HValue* obj = Pop(); | 10030 HValue* obj = Pop(); |
10030 HValue* function = AddLoadJSBuiltin(Builtins::DELETE); | 10031 HValue* function = AddLoadJSBuiltin(Builtins::DELETE); |
10031 Add<HPushArguments>(obj, key, Add<HConstant>(function_strict_mode())); | 10032 Add<HPushArguments>(obj, key, Add<HConstant>(function_language_mode())); |
10032 // TODO(olivf) InvokeFunction produces a check for the parameter count, | 10033 // TODO(olivf) InvokeFunction produces a check for the parameter count, |
10033 // even though we are certain to pass the correct number of arguments here. | 10034 // even though we are certain to pass the correct number of arguments here. |
10034 HInstruction* instr = New<HInvokeFunction>(function, 3); | 10035 HInstruction* instr = New<HInvokeFunction>(function, 3); |
10035 return ast_context()->ReturnInstruction(instr, expr->id()); | 10036 return ast_context()->ReturnInstruction(instr, expr->id()); |
10036 } else if (proxy != NULL) { | 10037 } else if (proxy != NULL) { |
10037 Variable* var = proxy->var(); | 10038 Variable* var = proxy->var(); |
10038 if (var->IsUnallocated()) { | 10039 if (var->IsUnallocated()) { |
10039 Bailout(kDeleteWithGlobalVariable); | 10040 Bailout(kDeleteWithGlobalVariable); |
10040 } else if (var->IsStackAllocated() || var->IsContextSlot()) { | 10041 } else if (var->IsStackAllocated() || var->IsContextSlot()) { |
10041 // Result of deleting non-global variables is false. 'this' is not | 10042 // Result of deleting non-global variables is false. 'this' is not |
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11428 | 11429 |
11429 | 11430 |
11430 void HOptimizedGraphBuilder::VisitDeclarations( | 11431 void HOptimizedGraphBuilder::VisitDeclarations( |
11431 ZoneList<Declaration*>* declarations) { | 11432 ZoneList<Declaration*>* declarations) { |
11432 DCHECK(globals_.is_empty()); | 11433 DCHECK(globals_.is_empty()); |
11433 AstVisitor::VisitDeclarations(declarations); | 11434 AstVisitor::VisitDeclarations(declarations); |
11434 if (!globals_.is_empty()) { | 11435 if (!globals_.is_empty()) { |
11435 Handle<FixedArray> array = | 11436 Handle<FixedArray> array = |
11436 isolate()->factory()->NewFixedArray(globals_.length(), TENURED); | 11437 isolate()->factory()->NewFixedArray(globals_.length(), TENURED); |
11437 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); | 11438 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); |
11438 int flags = DeclareGlobalsEvalFlag::encode(current_info()->is_eval()) | | 11439 int flags = |
| 11440 DeclareGlobalsEvalFlag::encode(current_info()->is_eval()) | |
11439 DeclareGlobalsNativeFlag::encode(current_info()->is_native()) | | 11441 DeclareGlobalsNativeFlag::encode(current_info()->is_native()) | |
11440 DeclareGlobalsStrictMode::encode(current_info()->strict_mode()); | 11442 DeclareGlobalsLanguageMode::encode(current_info()->language_mode()); |
11441 Add<HDeclareGlobals>(array, flags); | 11443 Add<HDeclareGlobals>(array, flags); |
11442 globals_.Rewind(0); | 11444 globals_.Rewind(0); |
11443 } | 11445 } |
11444 } | 11446 } |
11445 | 11447 |
11446 | 11448 |
11447 void HOptimizedGraphBuilder::VisitVariableDeclaration( | 11449 void HOptimizedGraphBuilder::VisitVariableDeclaration( |
11448 VariableDeclaration* declaration) { | 11450 VariableDeclaration* declaration) { |
11449 VariableProxy* proxy = declaration->proxy(); | 11451 VariableProxy* proxy = declaration->proxy(); |
11450 VariableMode mode = declaration->mode(); | 11452 VariableMode mode = declaration->mode(); |
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13478 if (ShouldProduceTraceOutput()) { | 13480 if (ShouldProduceTraceOutput()) { |
13479 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13481 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13480 } | 13482 } |
13481 | 13483 |
13482 #ifdef DEBUG | 13484 #ifdef DEBUG |
13483 graph_->Verify(false); // No full verify. | 13485 graph_->Verify(false); // No full verify. |
13484 #endif | 13486 #endif |
13485 } | 13487 } |
13486 | 13488 |
13487 } } // namespace v8::internal | 13489 } } // namespace v8::internal |
OLD | NEW |