Chromium Code Reviews

Side by Side Diff: src/hydrogen.cc

Issue 894683003: Introduce LanguageMode, drop StrictMode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: . Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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...)
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...)
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_strict(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...)
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...)
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 1990 matching lines...)
8932 int call_index = args_length + 1; 8933 int call_index = args_length + 1;
8933 environment()->RemoveExpressionStackAt(call_index); 8934 environment()->RemoveExpressionStackAt(call_index);
8934 8935
8935 HandleIndirectCall(expr, function, args_length); 8936 HandleIndirectCall(expr, function, args_length);
8936 } 8937 }
8937 8938
8938 8939
8939 HValue* HOptimizedGraphBuilder::ImplicitReceiverFor(HValue* function, 8940 HValue* HOptimizedGraphBuilder::ImplicitReceiverFor(HValue* function,
8940 Handle<JSFunction> target) { 8941 Handle<JSFunction> target) {
8941 SharedFunctionInfo* shared = target->shared(); 8942 SharedFunctionInfo* shared = target->shared();
8942 if (shared->strict_mode() == SLOPPY && !shared->native()) { 8943 if (!is_strict(shared->language_mode()) && !shared->native()) {
8943 // Cannot embed a direct reference to the global proxy 8944 // Cannot embed a direct reference to the global proxy
8944 // as is it dropped on deserialization. 8945 // as is it dropped on deserialization.
8945 CHECK(!isolate()->serializer_enabled()); 8946 CHECK(!isolate()->serializer_enabled());
8946 Handle<JSObject> global_proxy(target->context()->global_proxy()); 8947 Handle<JSObject> global_proxy(target->context()->global_proxy());
8947 return Add<HConstant>(global_proxy); 8948 return Add<HConstant>(global_proxy);
8948 } 8949 }
8949 return graph()->GetConstantUndefined(); 8950 return graph()->GetConstantUndefined();
8950 } 8951 }
8951 8952
8952 8953
(...skipping 1066 matching lines...)
10019 10020
10020 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) { 10021 void HOptimizedGraphBuilder::VisitDelete(UnaryOperation* expr) {
10021 Property* prop = expr->expression()->AsProperty(); 10022 Property* prop = expr->expression()->AsProperty();
10022 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 10023 VariableProxy* proxy = expr->expression()->AsVariableProxy();
10023 if (prop != NULL) { 10024 if (prop != NULL) {
10024 CHECK_ALIVE(VisitForValue(prop->obj())); 10025 CHECK_ALIVE(VisitForValue(prop->obj()));
10025 CHECK_ALIVE(VisitForValue(prop->key())); 10026 CHECK_ALIVE(VisitForValue(prop->key()));
10026 HValue* key = Pop(); 10027 HValue* key = Pop();
10027 HValue* obj = Pop(); 10028 HValue* obj = Pop();
10028 HValue* function = AddLoadJSBuiltin(Builtins::DELETE); 10029 HValue* function = AddLoadJSBuiltin(Builtins::DELETE);
10029 Add<HPushArguments>(obj, key, Add<HConstant>(function_strict_mode())); 10030 Add<HPushArguments>(obj, key, Add<HConstant>(function_language_mode()));
10030 // TODO(olivf) InvokeFunction produces a check for the parameter count, 10031 // TODO(olivf) InvokeFunction produces a check for the parameter count,
10031 // even though we are certain to pass the correct number of arguments here. 10032 // even though we are certain to pass the correct number of arguments here.
10032 HInstruction* instr = New<HInvokeFunction>(function, 3); 10033 HInstruction* instr = New<HInvokeFunction>(function, 3);
10033 return ast_context()->ReturnInstruction(instr, expr->id()); 10034 return ast_context()->ReturnInstruction(instr, expr->id());
10034 } else if (proxy != NULL) { 10035 } else if (proxy != NULL) {
10035 Variable* var = proxy->var(); 10036 Variable* var = proxy->var();
10036 if (var->IsUnallocated()) { 10037 if (var->IsUnallocated()) {
10037 Bailout(kDeleteWithGlobalVariable); 10038 Bailout(kDeleteWithGlobalVariable);
10038 } else if (var->IsStackAllocated() || var->IsContextSlot()) { 10039 } else if (var->IsStackAllocated() || var->IsContextSlot()) {
10039 // Result of deleting non-global variables is false. 'this' is not 10040 // Result of deleting non-global variables is false. 'this' is not
(...skipping 1386 matching lines...)
11426 11427
11427 11428
11428 void HOptimizedGraphBuilder::VisitDeclarations( 11429 void HOptimizedGraphBuilder::VisitDeclarations(
11429 ZoneList<Declaration*>* declarations) { 11430 ZoneList<Declaration*>* declarations) {
11430 DCHECK(globals_.is_empty()); 11431 DCHECK(globals_.is_empty());
11431 AstVisitor::VisitDeclarations(declarations); 11432 AstVisitor::VisitDeclarations(declarations);
11432 if (!globals_.is_empty()) { 11433 if (!globals_.is_empty()) {
11433 Handle<FixedArray> array = 11434 Handle<FixedArray> array =
11434 isolate()->factory()->NewFixedArray(globals_.length(), TENURED); 11435 isolate()->factory()->NewFixedArray(globals_.length(), TENURED);
11435 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); 11436 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i));
11436 int flags = DeclareGlobalsEvalFlag::encode(current_info()->is_eval()) | 11437 int flags =
11438 DeclareGlobalsEvalFlag::encode(current_info()->is_eval()) |
11437 DeclareGlobalsNativeFlag::encode(current_info()->is_native()) | 11439 DeclareGlobalsNativeFlag::encode(current_info()->is_native()) |
11438 DeclareGlobalsStrictMode::encode(current_info()->strict_mode()); 11440 DeclareGlobalsLanguageMode::encode(current_info()->language_mode());
11439 Add<HDeclareGlobals>(array, flags); 11441 Add<HDeclareGlobals>(array, flags);
11440 globals_.Rewind(0); 11442 globals_.Rewind(0);
11441 } 11443 }
11442 } 11444 }
11443 11445
11444 11446
11445 void HOptimizedGraphBuilder::VisitVariableDeclaration( 11447 void HOptimizedGraphBuilder::VisitVariableDeclaration(
11446 VariableDeclaration* declaration) { 11448 VariableDeclaration* declaration) {
11447 VariableProxy* proxy = declaration->proxy(); 11449 VariableProxy* proxy = declaration->proxy();
11448 VariableMode mode = declaration->mode(); 11450 VariableMode mode = declaration->mode();
(...skipping 2027 matching lines...)
13476 if (ShouldProduceTraceOutput()) { 13478 if (ShouldProduceTraceOutput()) {
13477 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13479 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13478 } 13480 }
13479 13481
13480 #ifdef DEBUG 13482 #ifdef DEBUG
13481 graph_->Verify(false); // No full verify. 13483 graph_->Verify(false); // No full verify.
13482 #endif 13484 #endif
13483 } 13485 }
13484 13486
13485 } } // namespace v8::internal 13487 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine