| 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return GetConstant(&constant_1_, Smi::FromInt(1)); | 505 return GetConstant(&constant_1_, Smi::FromInt(1)); |
| 506 } | 506 } |
| 507 | 507 |
| 508 | 508 |
| 509 HConstant* HGraph::GetConstantMinus1() { | 509 HConstant* HGraph::GetConstantMinus1() { |
| 510 return GetConstant(&constant_minus1_, Smi::FromInt(-1)); | 510 return GetConstant(&constant_minus1_, Smi::FromInt(-1)); |
| 511 } | 511 } |
| 512 | 512 |
| 513 | 513 |
| 514 HConstant* HGraph::GetConstantTrue() { | 514 HConstant* HGraph::GetConstantTrue() { |
| 515 return GetConstant(&constant_true_, HEAP->true_value()); | 515 return GetConstant(&constant_true_, isolate()->heap()->true_value()); |
| 516 } | 516 } |
| 517 | 517 |
| 518 | 518 |
| 519 HConstant* HGraph::GetConstantFalse() { | 519 HConstant* HGraph::GetConstantFalse() { |
| 520 return GetConstant(&constant_false_, HEAP->false_value()); | 520 return GetConstant(&constant_false_, isolate()->heap()->false_value()); |
| 521 } | 521 } |
| 522 | 522 |
| 523 | 523 |
| 524 HBasicBlock* HGraphBuilder::CreateJoin(HBasicBlock* first, | 524 HBasicBlock* HGraphBuilder::CreateJoin(HBasicBlock* first, |
| 525 HBasicBlock* second, | 525 HBasicBlock* second, |
| 526 int join_id) { | 526 int join_id) { |
| 527 if (first == NULL) { | 527 if (first == NULL) { |
| 528 return second; | 528 return second; |
| 529 } else if (second == NULL) { | 529 } else if (second == NULL) { |
| 530 return first; | 530 return first; |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 } | 1241 } |
| 1242 | 1242 |
| 1243 | 1243 |
| 1244 class HGlobalValueNumberer BASE_EMBEDDED { | 1244 class HGlobalValueNumberer BASE_EMBEDDED { |
| 1245 public: | 1245 public: |
| 1246 explicit HGlobalValueNumberer(HGraph* graph, CompilationInfo* info) | 1246 explicit HGlobalValueNumberer(HGraph* graph, CompilationInfo* info) |
| 1247 : graph_(graph), | 1247 : graph_(graph), |
| 1248 info_(info), | 1248 info_(info), |
| 1249 block_side_effects_(graph_->blocks()->length()), | 1249 block_side_effects_(graph_->blocks()->length()), |
| 1250 loop_side_effects_(graph_->blocks()->length()) { | 1250 loop_side_effects_(graph_->blocks()->length()) { |
| 1251 ASSERT(HEAP->allow_allocation(false)); | 1251 ASSERT(info->isolate()->heap()->allow_allocation(false)); |
| 1252 block_side_effects_.AddBlock(0, graph_->blocks()->length()); | 1252 block_side_effects_.AddBlock(0, graph_->blocks()->length()); |
| 1253 loop_side_effects_.AddBlock(0, graph_->blocks()->length()); | 1253 loop_side_effects_.AddBlock(0, graph_->blocks()->length()); |
| 1254 } | 1254 } |
| 1255 ~HGlobalValueNumberer() { | 1255 ~HGlobalValueNumberer() { |
| 1256 ASSERT(!HEAP->allow_allocation(true)); | 1256 ASSERT(!info_->isolate()->heap()->allow_allocation(true)); |
| 1257 } | 1257 } |
| 1258 | 1258 |
| 1259 void Analyze(); | 1259 void Analyze(); |
| 1260 | 1260 |
| 1261 private: | 1261 private: |
| 1262 void AnalyzeBlock(HBasicBlock* block, HValueMap* map); | 1262 void AnalyzeBlock(HBasicBlock* block, HValueMap* map); |
| 1263 void ComputeBlockSideEffects(); | 1263 void ComputeBlockSideEffects(); |
| 1264 void LoopInvariantCodeMotion(); | 1264 void LoopInvariantCodeMotion(); |
| 1265 void ProcessLoopBlock(HBasicBlock* block, | 1265 void ProcessLoopBlock(HBasicBlock* block, |
| 1266 HBasicBlock* before_loop, | 1266 HBasicBlock* before_loop, |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2271 AddInstruction(new HPushArgument(arguments.RemoveLast())); | 2271 AddInstruction(new HPushArgument(arguments.RemoveLast())); |
| 2272 } | 2272 } |
| 2273 return call; | 2273 return call; |
| 2274 } | 2274 } |
| 2275 | 2275 |
| 2276 | 2276 |
| 2277 void HGraphBuilder::SetupScope(Scope* scope) { | 2277 void HGraphBuilder::SetupScope(Scope* scope) { |
| 2278 // We don't yet handle the function name for named function expressions. | 2278 // We don't yet handle the function name for named function expressions. |
| 2279 if (scope->function() != NULL) BAILOUT("named function expression"); | 2279 if (scope->function() != NULL) BAILOUT("named function expression"); |
| 2280 | 2280 |
| 2281 HConstant* undefined_constant = | 2281 HConstant* undefined_constant = new HConstant( |
| 2282 new HConstant(FACTORY->undefined_value(), Representation::Tagged()); | 2282 isolate()->factory()->undefined_value(), Representation::Tagged()); |
| 2283 AddInstruction(undefined_constant); | 2283 AddInstruction(undefined_constant); |
| 2284 graph_->set_undefined_constant(undefined_constant); | 2284 graph_->set_undefined_constant(undefined_constant); |
| 2285 | 2285 |
| 2286 // Set the initial values of parameters including "this". "This" has | 2286 // Set the initial values of parameters including "this". "This" has |
| 2287 // parameter index 0. | 2287 // parameter index 0. |
| 2288 int count = scope->num_parameters() + 1; | 2288 int count = scope->num_parameters() + 1; |
| 2289 for (int i = 0; i < count; ++i) { | 2289 for (int i = 0; i < count; ++i) { |
| 2290 HInstruction* parameter = AddInstruction(new HParameter(i)); | 2290 HInstruction* parameter = AddInstruction(new HParameter(i)); |
| 2291 environment()->Bind(i, parameter); | 2291 environment()->Bind(i, parameter); |
| 2292 } | 2292 } |
| (...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3618 HInstruction* HGraphBuilder::BuildStoreKeyedFastElement(HValue* object, | 3618 HInstruction* HGraphBuilder::BuildStoreKeyedFastElement(HValue* object, |
| 3619 HValue* key, | 3619 HValue* key, |
| 3620 HValue* val, | 3620 HValue* val, |
| 3621 Expression* expr) { | 3621 Expression* expr) { |
| 3622 ASSERT(expr->IsMonomorphic()); | 3622 ASSERT(expr->IsMonomorphic()); |
| 3623 AddInstruction(new HCheckNonSmi(object)); | 3623 AddInstruction(new HCheckNonSmi(object)); |
| 3624 Handle<Map> map = expr->GetMonomorphicReceiverType(); | 3624 Handle<Map> map = expr->GetMonomorphicReceiverType(); |
| 3625 ASSERT(map->has_fast_elements()); | 3625 ASSERT(map->has_fast_elements()); |
| 3626 AddInstruction(new HCheckMap(object, map)); | 3626 AddInstruction(new HCheckMap(object, map)); |
| 3627 HInstruction* elements = AddInstruction(new HLoadElements(object)); | 3627 HInstruction* elements = AddInstruction(new HLoadElements(object)); |
| 3628 AddInstruction(new HCheckMap(elements, FACTORY->fixed_array_map())); | 3628 AddInstruction(new HCheckMap(elements, |
| 3629 isolate()->factory()->fixed_array_map())); |
| 3629 bool is_array = (map->instance_type() == JS_ARRAY_TYPE); | 3630 bool is_array = (map->instance_type() == JS_ARRAY_TYPE); |
| 3630 HInstruction* length = NULL; | 3631 HInstruction* length = NULL; |
| 3631 if (is_array) { | 3632 if (is_array) { |
| 3632 length = AddInstruction(new HJSArrayLength(object)); | 3633 length = AddInstruction(new HJSArrayLength(object)); |
| 3633 } else { | 3634 } else { |
| 3634 length = AddInstruction(new HFixedArrayLength(elements)); | 3635 length = AddInstruction(new HFixedArrayLength(elements)); |
| 3635 } | 3636 } |
| 3636 AddInstruction(new HBoundsCheck(key, length)); | 3637 AddInstruction(new HBoundsCheck(key, length)); |
| 3637 return new HStoreKeyedFastElement(elements, key, val); | 3638 return new HStoreKeyedFastElement(elements, key, val); |
| 3638 } | 3639 } |
| (...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4968 Handle<String> name = var->name(); | 4969 Handle<String> name = var->name(); |
| 4969 Handle<GlobalObject> global(info()->global_object()); | 4970 Handle<GlobalObject> global(info()->global_object()); |
| 4970 LookupResult lookup; | 4971 LookupResult lookup; |
| 4971 global->Lookup(*name, &lookup); | 4972 global->Lookup(*name, &lookup); |
| 4972 if (lookup.IsProperty() && | 4973 if (lookup.IsProperty() && |
| 4973 lookup.type() == NORMAL && | 4974 lookup.type() == NORMAL && |
| 4974 lookup.GetValue()->IsJSFunction()) { | 4975 lookup.GetValue()->IsJSFunction()) { |
| 4975 Handle<JSFunction> candidate(JSFunction::cast(lookup.GetValue())); | 4976 Handle<JSFunction> candidate(JSFunction::cast(lookup.GetValue())); |
| 4976 // If the function is in new space we assume it's more likely to | 4977 // If the function is in new space we assume it's more likely to |
| 4977 // change and thus prefer the general IC code. | 4978 // change and thus prefer the general IC code. |
| 4978 if (!Isolate::Current()->heap()->InNewSpace(*candidate)) { | 4979 if (!isolate()->heap()->InNewSpace(*candidate)) { |
| 4979 target = candidate; | 4980 target = candidate; |
| 4980 } | 4981 } |
| 4981 } | 4982 } |
| 4982 } | 4983 } |
| 4983 | 4984 |
| 4984 // If the target is not null we have found a known global function that is | 4985 // If the target is not null we have found a known global function that is |
| 4985 // assumed to stay the same for this instanceof. | 4986 // assumed to stay the same for this instanceof. |
| 4986 if (target.is_null()) { | 4987 if (target.is_null()) { |
| 4987 HContext* context = new HContext; | 4988 HContext* context = new HContext; |
| 4988 AddInstruction(context); | 4989 AddInstruction(context); |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5927 } | 5928 } |
| 5928 } | 5929 } |
| 5929 | 5930 |
| 5930 #ifdef DEBUG | 5931 #ifdef DEBUG |
| 5931 if (graph_ != NULL) graph_->Verify(); | 5932 if (graph_ != NULL) graph_->Verify(); |
| 5932 if (allocator_ != NULL) allocator_->Verify(); | 5933 if (allocator_ != NULL) allocator_->Verify(); |
| 5933 #endif | 5934 #endif |
| 5934 } | 5935 } |
| 5935 | 5936 |
| 5936 } } // namespace v8::internal | 5937 } } // namespace v8::internal |
| OLD | NEW |