| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 4210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4221 new ZoneGrowableArray<Value*>(call->ArgumentCount()); | 4221 new ZoneGrowableArray<Value*>(call->ArgumentCount()); |
| 4222 for (intptr_t i = 0; i < call->ArgumentCount(); i++) { | 4222 for (intptr_t i = 0; i < call->ArgumentCount(); i++) { |
| 4223 args->Add(new Value(call->ArgumentAt(i))); | 4223 args->Add(new Value(call->ArgumentAt(i))); |
| 4224 } | 4224 } |
| 4225 InvokeMathCFunctionInstr* invoke = | 4225 InvokeMathCFunctionInstr* invoke = |
| 4226 new InvokeMathCFunctionInstr(args, | 4226 new InvokeMathCFunctionInstr(args, |
| 4227 call->deopt_id(), | 4227 call->deopt_id(), |
| 4228 recognized_kind, | 4228 recognized_kind, |
| 4229 call->token_pos()); | 4229 call->token_pos()); |
| 4230 ReplaceCall(call, invoke); | 4230 ReplaceCall(call, invoke); |
| 4231 } else if (recognized_kind == MethodRecognizer::kObjectArrayConstructor) { |
| 4232 Value* type = new Value(call->ArgumentAt(0)); |
| 4233 Value* num_elements = new Value(call->ArgumentAt(1)); |
| 4234 CreateArrayInstr* create_array = |
| 4235 new CreateArrayInstr(call->token_pos(), type, num_elements); |
| 4236 ReplaceCall(call, create_array); |
| 4231 } else if (Library::PrivateCoreLibName(Symbols::ClassId()).Equals( | 4237 } else if (Library::PrivateCoreLibName(Symbols::ClassId()).Equals( |
| 4232 String::Handle(call->function().name()))) { | 4238 String::Handle(call->function().name()))) { |
| 4233 // Check for core library get:_classId. | 4239 // Check for core library get:_classId. |
| 4234 intptr_t cid = Class::Handle(call->function().Owner()).id(); | 4240 intptr_t cid = Class::Handle(call->function().Owner()).id(); |
| 4235 // Currently only implemented for a subset of classes. | 4241 // Currently only implemented for a subset of classes. |
| 4236 ASSERT((cid == kOneByteStringCid) || (cid == kTwoByteStringCid) || | 4242 ASSERT((cid == kOneByteStringCid) || (cid == kTwoByteStringCid) || |
| 4237 (cid == kExternalOneByteStringCid) || | 4243 (cid == kExternalOneByteStringCid) || |
| 4238 (cid == kGrowableObjectArrayCid) || | 4244 (cid == kGrowableObjectArrayCid) || |
| 4239 (cid == kImmutableArrayCid) || (cid == kArrayCid)); | 4245 (cid == kImmutableArrayCid) || (cid == kArrayCid)); |
| 4240 ConstantInstr* cid_instr = new ConstantInstr(Smi::Handle(Smi::New(cid))); | 4246 ConstantInstr* cid_instr = new ConstantInstr(Smi::Handle(Smi::New(cid))); |
| 4241 ReplaceCall(call, cid_instr); | 4247 ReplaceCall(call, cid_instr); |
| 4242 } | 4248 } else if (call->function().IsFactory()) { |
| 4243 | |
| 4244 if (call->function().IsFactory()) { | |
| 4245 const Class& function_class = Class::Handle(call->function().Owner()); | 4249 const Class& function_class = Class::Handle(call->function().Owner()); |
| 4246 if ((function_class.library() == Library::CoreLibrary()) || | 4250 if ((function_class.library() == Library::CoreLibrary()) || |
| 4247 (function_class.library() == Library::TypedDataLibrary())) { | 4251 (function_class.library() == Library::TypedDataLibrary())) { |
| 4248 intptr_t cid = FactoryRecognizer::ResultCid(call->function()); | 4252 intptr_t cid = FactoryRecognizer::ResultCid(call->function()); |
| 4249 switch (cid) { | 4253 switch (cid) { |
| 4250 case kArrayCid: { | 4254 case kArrayCid: { |
| 4251 Value* type = new Value(call->ArgumentAt(0)); | 4255 Value* type = new Value(call->ArgumentAt(0)); |
| 4252 Value* num_elements = new Value(call->ArgumentAt(1)); | 4256 Value* num_elements = new Value(call->ArgumentAt(1)); |
| 4253 if (num_elements->BindsToConstant() && | 4257 if (num_elements->BindsToConstant() && |
| 4254 num_elements->BoundConstant().IsSmi()) { | 4258 num_elements->BoundConstant().IsSmi()) { |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5010 !block_it.Done(); | 5014 !block_it.Done(); |
| 5011 block_it.Advance()) { | 5015 block_it.Advance()) { |
| 5012 BlockEntryInstr* block = block_it.Current(); | 5016 BlockEntryInstr* block = block_it.Current(); |
| 5013 if (block->try_index() == catch_entry->catch_try_index()) { | 5017 if (block->try_index() == catch_entry->catch_try_index()) { |
| 5014 for (ForwardInstructionIterator instr_it(block); | 5018 for (ForwardInstructionIterator instr_it(block); |
| 5015 !instr_it.Done(); | 5019 !instr_it.Done(); |
| 5016 instr_it.Advance()) { | 5020 instr_it.Advance()) { |
| 5017 Instruction* current = instr_it.Current(); | 5021 Instruction* current = instr_it.Current(); |
| 5018 if (current->MayThrow()) { | 5022 if (current->MayThrow()) { |
| 5019 Environment* env = current->env(); | 5023 Environment* env = current->env(); |
| 5024 ASSERT(env != NULL); |
| 5020 for (intptr_t env_idx = 0; env_idx < cdefs.length(); ++env_idx) { | 5025 for (intptr_t env_idx = 0; env_idx < cdefs.length(); ++env_idx) { |
| 5021 if (cdefs[env_idx] != NULL && | 5026 if (cdefs[env_idx] != NULL && |
| 5022 env->ValueAt(env_idx)->BindsToConstant()) { | 5027 env->ValueAt(env_idx)->BindsToConstant()) { |
| 5023 cdefs[env_idx] = env->ValueAt(env_idx)->definition(); | 5028 cdefs[env_idx] = env->ValueAt(env_idx)->definition(); |
| 5024 } | 5029 } |
| 5025 if (cdefs[env_idx] != env->ValueAt(env_idx)->definition()) { | 5030 if (cdefs[env_idx] != env->ValueAt(env_idx)->definition()) { |
| 5026 cdefs[env_idx] = NULL; | 5031 cdefs[env_idx] = NULL; |
| 5027 } | 5032 } |
| 5028 } | 5033 } |
| 5029 } | 5034 } |
| (...skipping 4592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9622 } | 9627 } |
| 9623 | 9628 |
| 9624 // Insert materializations at environment uses. | 9629 // Insert materializations at environment uses. |
| 9625 for (intptr_t i = 0; i < exits.length(); i++) { | 9630 for (intptr_t i = 0; i < exits.length(); i++) { |
| 9626 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); | 9631 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *slots); |
| 9627 } | 9632 } |
| 9628 } | 9633 } |
| 9629 | 9634 |
| 9630 | 9635 |
| 9631 } // namespace dart | 9636 } // namespace dart |
| OLD | NEW |