OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 } | 863 } |
864 } | 864 } |
865 // Replace the uses and add phis modified to the work list. | 865 // Replace the uses and add phis modified to the work list. |
866 for (int i = 0; i < uses_to_replace.length(); ++i) { | 866 for (int i = 0; i < uses_to_replace.length(); ++i) { |
867 HValue* use = uses_to_replace[i]; | 867 HValue* use = uses_to_replace[i]; |
868 phi->ReplaceAtUse(use, value); | 868 phi->ReplaceAtUse(use, value); |
869 if (use->IsPhi()) worklist.Add(HPhi::cast(use)); | 869 if (use->IsPhi()) worklist.Add(HPhi::cast(use)); |
870 } | 870 } |
871 uses_to_replace.Rewind(0); | 871 uses_to_replace.Rewind(0); |
872 block->RemovePhi(phi); | 872 block->RemovePhi(phi); |
873 } else if (phi->HasNoUses() && | 873 } else if (FLAG_eliminate_dead_phis && phi->HasNoUses() && |
874 !phi->HasReceiverOperand() && | 874 !phi->IsReceiver()) { |
875 FLAG_eliminate_dead_phis) { | 875 // We can't eliminate phis in the receiver position in the environment |
876 // We can't eliminate phis that have the receiver as an operand | 876 // because in case of throwing an error we need this value to |
877 // because in case of throwing an error we need the correct | 877 // construct a stack trace. |
878 // receiver value in the environment to construct a corrent | |
879 // stack trace. | |
880 block->RemovePhi(phi); | 878 block->RemovePhi(phi); |
881 block->RecordDeletedPhi(phi->merged_index()); | 879 block->RecordDeletedPhi(phi->merged_index()); |
882 } | 880 } |
883 } | 881 } |
884 } | 882 } |
885 | 883 |
886 | 884 |
887 bool HGraph::CollectPhis() { | 885 bool HGraph::CollectPhis() { |
888 const ZoneList<HBasicBlock*>* blocks = graph_->blocks(); | 886 const ZoneList<HBasicBlock*>* blocks = graph_->blocks(); |
889 phi_list_ = new ZoneList<HPhi*>(blocks->length()); | 887 phi_list_ = new ZoneList<HPhi*>(blocks->length()); |
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2945 global->Lookup(*var->name(), lookup); | 2943 global->Lookup(*var->name(), lookup); |
2946 if (!lookup->IsProperty()) { | 2944 if (!lookup->IsProperty()) { |
2947 BAILOUT("global variable cell not yet introduced"); | 2945 BAILOUT("global variable cell not yet introduced"); |
2948 } | 2946 } |
2949 if (lookup->type() != NORMAL) { | 2947 if (lookup->type() != NORMAL) { |
2950 BAILOUT("global variable has accessors"); | 2948 BAILOUT("global variable has accessors"); |
2951 } | 2949 } |
2952 if (is_store && lookup->IsReadOnly()) { | 2950 if (is_store && lookup->IsReadOnly()) { |
2953 BAILOUT("read-only global variable"); | 2951 BAILOUT("read-only global variable"); |
2954 } | 2952 } |
| 2953 if (lookup->holder() != *global) { |
| 2954 BAILOUT("global property on prototype of global object"); |
| 2955 } |
2955 } | 2956 } |
2956 | 2957 |
2957 | 2958 |
2958 HValue* HGraphBuilder::BuildContextChainWalk(Variable* var) { | 2959 HValue* HGraphBuilder::BuildContextChainWalk(Variable* var) { |
2959 ASSERT(var->IsContextSlot()); | 2960 ASSERT(var->IsContextSlot()); |
2960 HInstruction* context = new HContext; | 2961 HInstruction* context = new HContext; |
2961 AddInstruction(context); | 2962 AddInstruction(context); |
2962 int length = graph()->info()->scope()->ContextChainLength(var->scope()); | 2963 int length = graph()->info()->scope()->ContextChainLength(var->scope()); |
2963 while (length-- > 0) { | 2964 while (length-- > 0) { |
2964 context = new HOuterContext(context); | 2965 context = new HOuterContext(context); |
(...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5178 } | 5179 } |
5179 | 5180 |
5180 | 5181 |
5181 void HGraphBuilder::GenerateIsStringWrapperSafeForDefaultValueOf( | 5182 void HGraphBuilder::GenerateIsStringWrapperSafeForDefaultValueOf( |
5182 int argument_count, | 5183 int argument_count, |
5183 int ast_id) { | 5184 int ast_id) { |
5184 BAILOUT("inlined runtime function: IsStringWrapperSafeForDefaultValueOf"); | 5185 BAILOUT("inlined runtime function: IsStringWrapperSafeForDefaultValueOf"); |
5185 } | 5186 } |
5186 | 5187 |
5187 | 5188 |
5188 // Support for construct call checks. | 5189 // Support for construct call checks. |
5189 void HGraphBuilder::GenerateIsConstructCall(int argument_count, int ast_id) { | 5190 void HGraphBuilder::GenerateIsConstructCall(int argument_count, int ast_id) { |
5190 BAILOUT("inlined runtime function: IsConstructCall"); | 5191 ASSERT(argument_count == 0); |
| 5192 ast_context()->ReturnInstruction(new HIsConstructCall, ast_id); |
5191 } | 5193 } |
5192 | 5194 |
5193 | 5195 |
5194 // Support for arguments.length and arguments[?]. | 5196 // Support for arguments.length and arguments[?]. |
5195 void HGraphBuilder::GenerateArgumentsLength(int argument_count, int ast_id) { | 5197 void HGraphBuilder::GenerateArgumentsLength(int argument_count, int ast_id) { |
5196 ASSERT(argument_count == 0); | 5198 ASSERT(argument_count == 0); |
5197 HInstruction* elements = AddInstruction(new HArgumentsElements); | 5199 HInstruction* elements = AddInstruction(new HArgumentsElements); |
5198 HArgumentsLength* result = new HArgumentsLength(elements); | 5200 HArgumentsLength* result = new HArgumentsLength(elements); |
5199 ast_context()->ReturnInstruction(result, ast_id); | 5201 ast_context()->ReturnInstruction(result, ast_id); |
5200 } | 5202 } |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5924 } | 5926 } |
5925 } | 5927 } |
5926 | 5928 |
5927 #ifdef DEBUG | 5929 #ifdef DEBUG |
5928 if (graph_ != NULL) graph_->Verify(); | 5930 if (graph_ != NULL) graph_->Verify(); |
5929 if (allocator_ != NULL) allocator_->Verify(); | 5931 if (allocator_ != NULL) allocator_->Verify(); |
5930 #endif | 5932 #endif |
5931 } | 5933 } |
5932 | 5934 |
5933 } } // namespace v8::internal | 5935 } } // namespace v8::internal |
OLD | NEW |