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

Side by Side Diff: src/hydrogen.cc

Issue 16925008: Generate StoreGlobal stubs with Hydrogen (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address feedback Created 7 years, 5 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
OLDNEW
1 // Copyright 2012 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
11 // with the distribution. 11 // with the distribution.
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 #define DEFINE_GET_CONSTANT(Name, name, htype, boolean_value) \ 642 #define DEFINE_GET_CONSTANT(Name, name, htype, boolean_value) \
643 HConstant* HGraph::GetConstant##Name() { \ 643 HConstant* HGraph::GetConstant##Name() { \
644 if (!constant_##name##_.is_set()) { \ 644 if (!constant_##name##_.is_set()) { \
645 HConstant* constant = new(zone()) HConstant( \ 645 HConstant* constant = new(zone()) HConstant( \
646 isolate()->factory()->name##_value(), \ 646 isolate()->factory()->name##_value(), \
647 UniqueValueId(isolate()->heap()->name##_value()), \ 647 UniqueValueId(isolate()->heap()->name##_value()), \
648 Representation::Tagged(), \ 648 Representation::Tagged(), \
649 htype, \ 649 htype, \
650 false, \ 650 false, \
651 true, \ 651 true, \
652 false, \
652 boolean_value); \ 653 boolean_value); \
653 constant->InsertAfter(GetConstantUndefined()); \ 654 constant->InsertAfter(GetConstantUndefined()); \
654 constant_##name##_.set(constant); \ 655 constant_##name##_.set(constant); \
655 } \ 656 } \
656 return constant_##name##_.get(); \ 657 return constant_##name##_.get(); \
657 } 658 }
658 659
659 660
660 DEFINE_GET_CONSTANT(True, true, HType::Boolean(), true) 661 DEFINE_GET_CONSTANT(True, true, HType::Boolean(), true)
661 DEFINE_GET_CONSTANT(False, false, HType::Boolean(), false) 662 DEFINE_GET_CONSTANT(False, false, HType::Boolean(), false)
662 DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false) 663 DEFINE_GET_CONSTANT(Hole, the_hole, HType::Tagged(), false)
663 DEFINE_GET_CONSTANT(Null, null, HType::Tagged(), false) 664 DEFINE_GET_CONSTANT(Null, null, HType::Tagged(), false)
664 665
665 666
666 #undef DEFINE_GET_CONSTANT 667 #undef DEFINE_GET_CONSTANT
667 668
668 669
669 HConstant* HGraph::GetInvalidContext() { 670 HConstant* HGraph::GetInvalidContext() {
670 return GetConstant(&constant_invalid_context_, 0xFFFFC0C7); 671 return GetConstant(&constant_invalid_context_, 0xFFFFC0C7);
671 } 672 }
672 673
673 674
675 bool HGraph::IsStandardConstant(HConstant* constant) {
676 if (constant == GetConstantUndefined()) return true;
677 if (constant == GetConstant0()) return true;
678 if (constant == GetConstant1()) return true;
679 if (constant == GetConstantMinus1()) return true;
680 if (constant == GetConstantTrue()) return true;
681 if (constant == GetConstantFalse()) return true;
682 if (constant == GetConstantHole()) return true;
683 if (constant == GetConstantNull()) return true;
684 return false;
685 }
686
687
674 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, int position) 688 HGraphBuilder::IfBuilder::IfBuilder(HGraphBuilder* builder, int position)
675 : builder_(builder), 689 : builder_(builder),
676 position_(position), 690 position_(position),
677 finished_(false), 691 finished_(false),
678 did_then_(false), 692 did_then_(false),
679 did_else_(false), 693 did_else_(false),
680 did_and_(false), 694 did_and_(false),
681 did_or_(false), 695 did_or_(false),
682 captured_(false), 696 captured_(false),
683 needs_compare_(true), 697 needs_compare_(true),
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 HValue* context = environment()->LookupContext(); 1012 HValue* context = environment()->LookupContext();
999 int num_parameters = graph()->info()->num_parameters(); 1013 int num_parameters = graph()->info()->num_parameters();
1000 HValue* params = Add<HConstant>(num_parameters); 1014 HValue* params = Add<HConstant>(num_parameters);
1001 HReturn* return_instruction = new(graph()->zone()) 1015 HReturn* return_instruction = new(graph()->zone())
1002 HReturn(value, context, params); 1016 HReturn(value, context, params);
1003 current_block()->FinishExit(return_instruction); 1017 current_block()->FinishExit(return_instruction);
1004 return return_instruction; 1018 return return_instruction;
1005 } 1019 }
1006 1020
1007 1021
1008 void HGraphBuilder::AddSoftDeoptimize() { 1022 void HGraphBuilder::AddSoftDeoptimize(SoftDeoptimizeMode mode) {
1009 isolate()->counters()->soft_deopts_requested()->Increment(); 1023 isolate()->counters()->soft_deopts_requested()->Increment();
1010 if (FLAG_always_opt) return; 1024 if (FLAG_always_opt && mode == CAN_OMIT_SOFT_DEOPT) return;
1011 if (current_block()->IsDeoptimizing()) return; 1025 if (current_block()->IsDeoptimizing()) return;
1012 Add<HSoftDeoptimize>(); 1026 Add<HSoftDeoptimize>();
1013 isolate()->counters()->soft_deopts_inserted()->Increment(); 1027 isolate()->counters()->soft_deopts_inserted()->Increment();
1014 current_block()->MarkAsDeoptimizing(); 1028 current_block()->MarkAsDeoptimizing();
1015 graph()->set_has_soft_deoptimize(true); 1029 graph()->set_has_soft_deoptimize(true);
1016 } 1030 }
1017 1031
1018 1032
1019 HBasicBlock* HGraphBuilder::CreateBasicBlock(HEnvironment* env) { 1033 HBasicBlock* HGraphBuilder::CreateBasicBlock(HEnvironment* env) {
1020 HBasicBlock* b = graph()->CreateBasicBlock(); 1034 HBasicBlock* b = graph()->CreateBasicBlock();
(...skipping 3970 matching lines...) Expand 10 before | Expand all | Expand 10 after
4991 LookupGlobalProperty(variable, &lookup, false); 5005 LookupGlobalProperty(variable, &lookup, false);
4992 5006
4993 if (type == kUseCell && 5007 if (type == kUseCell &&
4994 current_info()->global_object()->IsAccessCheckNeeded()) { 5008 current_info()->global_object()->IsAccessCheckNeeded()) {
4995 type = kUseGeneric; 5009 type = kUseGeneric;
4996 } 5010 }
4997 5011
4998 if (type == kUseCell) { 5012 if (type == kUseCell) {
4999 Handle<GlobalObject> global(current_info()->global_object()); 5013 Handle<GlobalObject> global(current_info()->global_object());
5000 Handle<PropertyCell> cell(global->GetPropertyCell(&lookup)); 5014 Handle<PropertyCell> cell(global->GetPropertyCell(&lookup));
5001 HLoadGlobalCell* instr = 5015 if (cell->type()->IsConstant()) {
5002 new(zone()) HLoadGlobalCell(cell, lookup.GetPropertyDetails()); 5016 cell->AddDependentCompilationInfo(top_info());
5003 return ast_context()->ReturnInstruction(instr, expr->id()); 5017 Handle<Object> constant_object = cell->type()->AsConstant();
5018 if (constant_object->IsConsString()) {
5019 constant_object =
5020 FlattenGetString(Handle<String>::cast(constant_object));
5021 }
5022 HConstant* constant = new(zone()) HConstant(constant_object);
5023 return ast_context()->ReturnInstruction(constant, expr->id());
5024 } else {
5025 HLoadGlobalCell* instr =
5026 new(zone()) HLoadGlobalCell(cell, lookup.GetPropertyDetails());
5027 return ast_context()->ReturnInstruction(instr, expr->id());
5028 }
5004 } else { 5029 } else {
5005 HValue* context = environment()->LookupContext(); 5030 HValue* context = environment()->LookupContext();
5006 HGlobalObject* global_object = new(zone()) HGlobalObject(context); 5031 HGlobalObject* global_object = new(zone()) HGlobalObject(context);
5007 AddInstruction(global_object); 5032 AddInstruction(global_object);
5008 HLoadGlobalGeneric* instr = 5033 HLoadGlobalGeneric* instr =
5009 new(zone()) HLoadGlobalGeneric(context, 5034 new(zone()) HLoadGlobalGeneric(context,
5010 global_object, 5035 global_object,
5011 variable->name(), 5036 variable->name(),
5012 ast_context()->is_for_typeof()); 5037 ast_context()->is_for_typeof());
5013 instr->set_position(expr->position()); 5038 instr->set_position(expr->position());
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
5904 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( 5929 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment(
5905 Variable* var, 5930 Variable* var,
5906 HValue* value, 5931 HValue* value,
5907 int position, 5932 int position,
5908 BailoutId ast_id) { 5933 BailoutId ast_id) {
5909 LookupResult lookup(isolate()); 5934 LookupResult lookup(isolate());
5910 GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, true); 5935 GlobalPropertyAccess type = LookupGlobalProperty(var, &lookup, true);
5911 if (type == kUseCell) { 5936 if (type == kUseCell) {
5912 Handle<GlobalObject> global(current_info()->global_object()); 5937 Handle<GlobalObject> global(current_info()->global_object());
5913 Handle<PropertyCell> cell(global->GetPropertyCell(&lookup)); 5938 Handle<PropertyCell> cell(global->GetPropertyCell(&lookup));
5914 HInstruction* instr = Add<HStoreGlobalCell>(value, cell, 5939 if (cell->type()->IsConstant()) {
5915 lookup.GetPropertyDetails()); 5940 IfBuilder builder(this);
5941 HValue* constant = Add<HConstant>(cell->type()->AsConstant());
5942 if (cell->type()->AsConstant()->IsNumber()) {
5943 builder.IfCompare(value, constant, Token::EQ);
5944 } else {
5945 builder.If<HCompareObjectEqAndBranch>(value, constant);
5946 }
5947 builder.Then();
5948 builder.Else();
5949 AddSoftDeoptimize(MUST_EMIT_SOFT_DEOPT);
5950 builder.End();
5951 }
5952 HInstruction* instr =
5953 Add<HStoreGlobalCell>(value, cell, lookup.GetPropertyDetails());
5916 instr->set_position(position); 5954 instr->set_position(position);
5917 if (instr->HasObservableSideEffects()) { 5955 if (instr->HasObservableSideEffects()) {
5918 AddSimulate(ast_id, REMOVABLE_SIMULATE); 5956 AddSimulate(ast_id, REMOVABLE_SIMULATE);
5919 } 5957 }
5920 } else { 5958 } else {
5921 HValue* context = environment()->LookupContext(); 5959 HValue* context = environment()->LookupContext();
5922 HGlobalObject* global_object = Add<HGlobalObject>(context); 5960 HGlobalObject* global_object = Add<HGlobalObject>(context);
5923 HStoreGlobalGeneric* instr = 5961 HStoreGlobalGeneric* instr =
5924 Add<HStoreGlobalGeneric>(context, global_object, var->name(), 5962 Add<HStoreGlobalGeneric>(context, global_object, var->name(),
5925 value, function_strict_mode_flag()); 5963 value, function_strict_mode_flag());
(...skipping 4894 matching lines...) Expand 10 before | Expand all | Expand 10 after
10820 if (ShouldProduceTraceOutput()) { 10858 if (ShouldProduceTraceOutput()) {
10821 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10859 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10822 } 10860 }
10823 10861
10824 #ifdef DEBUG 10862 #ifdef DEBUG
10825 graph_->Verify(false); // No full verify. 10863 graph_->Verify(false); // No full verify.
10826 #endif 10864 #endif
10827 } 10865 }
10828 10866
10829 } } // namespace v8::internal 10867 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | src/x64/lithium-gap-resolver-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698