Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Side by Side Diff: src/hydrogen.cc

Issue 148453009: Both HGlobalObject and HGlobalReceiver can be replaced with HLoadNamedField. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2679 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 HInstruction* global_object = Add<HLoadNamedField>(context, 2690 HInstruction* global_object = Add<HLoadNamedField>(context,
2691 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); 2691 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
2692 HObjectAccess access = HObjectAccess::ForJSObjectOffset( 2692 HObjectAccess access = HObjectAccess::ForJSObjectOffset(
2693 GlobalObject::kNativeContextOffset); 2693 GlobalObject::kNativeContextOffset);
2694 return Add<HLoadNamedField>(global_object, access); 2694 return Add<HLoadNamedField>(global_object, access);
2695 } 2695 }
2696 2696
2697 2697
2698 HInstruction* HGraphBuilder::BuildGetNativeContext() { 2698 HInstruction* HGraphBuilder::BuildGetNativeContext() {
2699 // Get the global context, then the native context 2699 // Get the global context, then the native context
2700 HInstruction* global_object = Add<HGlobalObject>(); 2700 HValue* global_object = Add<HLoadNamedField>(
2701 HObjectAccess access = HObjectAccess::ForJSObjectOffset( 2701 context(), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
2702 GlobalObject::kNativeContextOffset); 2702 return Add<HLoadNamedField>(
2703 return Add<HLoadNamedField>(global_object, access); 2703 global_object, HObjectAccess::ForJSObjectOffset(
2704 GlobalObject::kNativeContextOffset));
2704 } 2705 }
2705 2706
2706 2707
2707 HInstruction* HGraphBuilder::BuildGetArrayFunction() { 2708 HInstruction* HGraphBuilder::BuildGetArrayFunction() {
2708 HInstruction* native_context = BuildGetNativeContext(); 2709 HInstruction* native_context = BuildGetNativeContext();
2709 HInstruction* index = 2710 HInstruction* index =
2710 Add<HConstant>(static_cast<int32_t>(Context::ARRAY_FUNCTION_INDEX)); 2711 Add<HConstant>(static_cast<int32_t>(Context::ARRAY_FUNCTION_INDEX));
2711 return Add<HLoadKeyed>( 2712 return Add<HLoadKeyed>(
2712 native_context, index, static_cast<HValue*>(NULL), FAST_ELEMENTS); 2713 native_context, index, static_cast<HValue*>(NULL), FAST_ELEMENTS);
2713 } 2714 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 2890
2890 2891
2891 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, 2892 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object,
2892 Handle<Map> map) { 2893 Handle<Map> map) {
2893 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(), 2894 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(),
2894 Add<HConstant>(map), INITIALIZING_STORE); 2895 Add<HConstant>(map), INITIALIZING_STORE);
2895 } 2896 }
2896 2897
2897 2898
2898 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) { 2899 HValue* HGraphBuilder::AddLoadJSBuiltin(Builtins::JavaScript builtin) {
2899 HGlobalObject* global_object = Add<HGlobalObject>(); 2900 HValue* global_object = Add<HLoadNamedField>(
2901 context(), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
2900 HObjectAccess access = HObjectAccess::ForJSObjectOffset( 2902 HObjectAccess access = HObjectAccess::ForJSObjectOffset(
2901 GlobalObject::kBuiltinsOffset); 2903 GlobalObject::kBuiltinsOffset);
2902 HValue* builtins = Add<HLoadNamedField>(global_object, access); 2904 HValue* builtins = Add<HLoadNamedField>(global_object, access);
2903 HObjectAccess function_access = HObjectAccess::ForJSObjectOffset( 2905 HObjectAccess function_access = HObjectAccess::ForJSObjectOffset(
2904 JSBuiltinsObject::OffsetOfFunctionWithId(builtin)); 2906 JSBuiltinsObject::OffsetOfFunctionWithId(builtin));
2905 return Add<HLoadNamedField>(builtins, function_access); 2907 return Add<HLoadNamedField>(builtins, function_access);
2906 } 2908 }
2907 2909
2908 2910
2909 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info) 2911 HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after
4770 FlattenGetString(Handle<String>::cast(constant_object)); 4772 FlattenGetString(Handle<String>::cast(constant_object));
4771 } 4773 }
4772 HConstant* constant = New<HConstant>(constant_object); 4774 HConstant* constant = New<HConstant>(constant_object);
4773 return ast_context()->ReturnInstruction(constant, expr->id()); 4775 return ast_context()->ReturnInstruction(constant, expr->id());
4774 } else { 4776 } else {
4775 HLoadGlobalCell* instr = 4777 HLoadGlobalCell* instr =
4776 New<HLoadGlobalCell>(cell, lookup.GetPropertyDetails()); 4778 New<HLoadGlobalCell>(cell, lookup.GetPropertyDetails());
4777 return ast_context()->ReturnInstruction(instr, expr->id()); 4779 return ast_context()->ReturnInstruction(instr, expr->id());
4778 } 4780 }
4779 } else { 4781 } else {
4780 HGlobalObject* global_object = Add<HGlobalObject>(); 4782 HValue* global_object = Add<HLoadNamedField>(
4783 context(), HObjectAccess::ForContextSlot(
4784 Context::GLOBAL_OBJECT_INDEX));
4781 HLoadGlobalGeneric* instr = 4785 HLoadGlobalGeneric* instr =
4782 New<HLoadGlobalGeneric>(global_object, 4786 New<HLoadGlobalGeneric>(global_object,
4783 variable->name(), 4787 variable->name(),
4784 ast_context()->is_for_typeof()); 4788 ast_context()->is_for_typeof());
4785 return ast_context()->ReturnInstruction(instr, expr->id()); 4789 return ast_context()->ReturnInstruction(instr, expr->id());
4786 } 4790 }
4787 } 4791 }
4788 4792
4789 case Variable::PARAMETER: 4793 case Variable::PARAMETER:
4790 case Variable::LOCAL: { 4794 case Variable::LOCAL: {
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
5894 Add<HDeoptimize>("Constant global variable assignment", 5898 Add<HDeoptimize>("Constant global variable assignment",
5895 Deoptimizer::EAGER); 5899 Deoptimizer::EAGER);
5896 builder.End(); 5900 builder.End();
5897 } 5901 }
5898 HInstruction* instr = 5902 HInstruction* instr =
5899 Add<HStoreGlobalCell>(value, cell, lookup.GetPropertyDetails()); 5903 Add<HStoreGlobalCell>(value, cell, lookup.GetPropertyDetails());
5900 if (instr->HasObservableSideEffects()) { 5904 if (instr->HasObservableSideEffects()) {
5901 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 5905 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
5902 } 5906 }
5903 } else { 5907 } else {
5904 HGlobalObject* global_object = Add<HGlobalObject>(); 5908 HValue* global_object = Add<HLoadNamedField>(
5909 context(), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
5905 HStoreNamedGeneric* instr = 5910 HStoreNamedGeneric* instr =
5906 Add<HStoreNamedGeneric>(global_object, var->name(), 5911 Add<HStoreNamedGeneric>(global_object, var->name(),
5907 value, function_strict_mode_flag()); 5912 value, function_strict_mode_flag());
5908 USE(instr); 5913 USE(instr);
5909 ASSERT(instr->HasObservableSideEffects()); 5914 ASSERT(instr->HasObservableSideEffects());
5910 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); 5915 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE);
5911 } 5916 }
5912 } 5917 }
5913 5918
5914 5919
(...skipping 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after
7947 LookupResult lookup(isolate()); 7952 LookupResult lookup(isolate());
7948 GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, false); 7953 GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, false);
7949 if (type == kUseCell && 7954 if (type == kUseCell &&
7950 !current_info()->global_object()->IsAccessCheckNeeded()) { 7955 !current_info()->global_object()->IsAccessCheckNeeded()) {
7951 Handle<GlobalObject> global(current_info()->global_object()); 7956 Handle<GlobalObject> global(current_info()->global_object());
7952 known_global_function = expr->ComputeGlobalTarget(global, &lookup); 7957 known_global_function = expr->ComputeGlobalTarget(global, &lookup);
7953 } 7958 }
7954 if (known_global_function) { 7959 if (known_global_function) {
7955 // Push the global object instead of the global receiver because 7960 // Push the global object instead of the global receiver because
7956 // code generated by the full code generator expects it. 7961 // code generated by the full code generator expects it.
7957 HGlobalObject* global_object = Add<HGlobalObject>(); 7962 HValue* global_object = Add<HLoadNamedField>(
7963 context(), HObjectAccess::ForContextSlot(
7964 Context::GLOBAL_OBJECT_INDEX));
7958 Push(global_object); 7965 Push(global_object);
7959 7966
7960 CHECK_ALIVE(VisitExpressions(expr->arguments())); 7967 CHECK_ALIVE(VisitExpressions(expr->arguments()));
7961 7968
7962 CHECK_ALIVE(VisitForValue(expr->expression())); 7969 CHECK_ALIVE(VisitForValue(expr->expression()));
7963 HValue* function = Pop(); 7970 HValue* function = Pop();
7964 Add<HCheckValue>(function, expr->target()); 7971 Add<HCheckValue>(function, expr->target());
7965 7972
7966 // Patch the global object on the stack by the expected receiver. 7973 // Patch the global object on the stack by the expected receiver.
7967 HValue* receiver = ImplicitReceiverFor(function, expr->target()); 7974 HValue* receiver = ImplicitReceiverFor(function, expr->target());
(...skipping 10 matching lines...) Expand all
7978 } 7985 }
7979 if (TryInlineCall(expr)) return; 7986 if (TryInlineCall(expr)) return;
7980 7987
7981 if (expr->target().is_identical_to(current_info()->closure())) { 7988 if (expr->target().is_identical_to(current_info()->closure())) {
7982 graph()->MarkRecursive(); 7989 graph()->MarkRecursive();
7983 } 7990 }
7984 7991
7985 if (CallStubCompiler::HasCustomCallGenerator(expr->target())) { 7992 if (CallStubCompiler::HasCustomCallGenerator(expr->target())) {
7986 // We're about to install a contextual IC, which expects the global 7993 // We're about to install a contextual IC, which expects the global
7987 // object as receiver rather than the global proxy. 7994 // object as receiver rather than the global proxy.
7988 HGlobalObject* global_object = Add<HGlobalObject>(); 7995 HValue* global_object = Add<HLoadNamedField>(
7996 context(), HObjectAccess::ForContextSlot(
7997 Context::GLOBAL_OBJECT_INDEX));
7989 const int receiver_index = argument_count - 1; 7998 const int receiver_index = argument_count - 1;
7990 environment()->SetExpressionStackAt(receiver_index, global_object); 7999 environment()->SetExpressionStackAt(receiver_index, global_object);
7991 // When the target has a custom call IC generator, use the IC, 8000 // When the target has a custom call IC generator, use the IC,
7992 // because it is likely to generate better code. 8001 // because it is likely to generate better code.
7993 call = NewCallNamed(var->name(), argument_count); 8002 call = NewCallNamed(var->name(), argument_count);
7994 PushArgumentsFromEnvironment(argument_count); 8003 PushArgumentsFromEnvironment(argument_count);
7995 } else { 8004 } else {
7996 call = BuildCallConstantFunction(expr->target(), argument_count); 8005 call = BuildCallConstantFunction(expr->target(), argument_count);
7997 PushArgumentsFromEnvironment(argument_count); 8006 PushArgumentsFromEnvironment(argument_count);
7998 } 8007 }
7999 } else { 8008 } else {
8000 HGlobalObject* receiver = Add<HGlobalObject>(); 8009 HValue* receiver = Add<HLoadNamedField>(
8010 context(), HObjectAccess::ForContextSlot(
8011 Context::GLOBAL_OBJECT_INDEX));
8001 Push(Add<HPushArgument>(receiver)); 8012 Push(Add<HPushArgument>(receiver));
8002 CHECK_ALIVE(VisitArgumentList(expr->arguments())); 8013 CHECK_ALIVE(VisitArgumentList(expr->arguments()));
8003 8014
8004 call = NewCallNamed(var->name(), argument_count); 8015 call = NewCallNamed(var->name(), argument_count);
8005 Drop(argument_count); 8016 Drop(argument_count);
8006 } 8017 }
8007 8018
8008 } else if (expr->IsMonomorphic()) { 8019 } else if (expr->IsMonomorphic()) {
8009 // The function is on the stack in the unoptimized code during 8020 // The function is on the stack in the unoptimized code during
8010 // evaluation of the arguments. 8021 // evaluation of the arguments.
(...skipping 3113 matching lines...) Expand 10 before | Expand all | Expand 10 after
11124 if (ShouldProduceTraceOutput()) { 11135 if (ShouldProduceTraceOutput()) {
11125 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11136 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11126 } 11137 }
11127 11138
11128 #ifdef DEBUG 11139 #ifdef DEBUG
11129 graph_->Verify(false); // No full verify. 11140 graph_->Verify(false); // No full verify.
11130 #endif 11141 #endif
11131 } 11142 }
11132 11143
11133 } } // namespace v8::internal 11144 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698