OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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_builder.h" | 5 #include "vm/flow_graph_builder.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 3474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3485 node->scope()->LookupVariable(Symbols::Value(), true); | 3485 node->scope()->LookupVariable(Symbols::Value(), true); |
3486 Value* value = Bind(new(Z) LoadLocalInstr(*value_var)); | 3486 Value* value = Bind(new(Z) LoadLocalInstr(*value_var)); |
3487 LoadClassIdInstr* load = new(Z) LoadClassIdInstr(value); | 3487 LoadClassIdInstr* load = new(Z) LoadClassIdInstr(value); |
3488 return ReturnDefinition(load); | 3488 return ReturnDefinition(load); |
3489 } | 3489 } |
3490 case MethodRecognizer::kGrowableArrayCapacity: { | 3490 case MethodRecognizer::kGrowableArrayCapacity: { |
3491 Value* receiver = Bind(BuildLoadThisVar(node->scope())); | 3491 Value* receiver = Bind(BuildLoadThisVar(node->scope())); |
3492 LoadFieldInstr* data_load = new(Z) LoadFieldInstr( | 3492 LoadFieldInstr* data_load = new(Z) LoadFieldInstr( |
3493 receiver, | 3493 receiver, |
3494 Array::data_offset(), | 3494 Array::data_offset(), |
3495 Type::ZoneHandle(Z, Type::DynamicType()), | 3495 Object::dynamic_type(), |
3496 node->token_pos()); | 3496 node->token_pos()); |
3497 data_load->set_result_cid(kArrayCid); | 3497 data_load->set_result_cid(kArrayCid); |
3498 Value* data = Bind(data_load); | 3498 Value* data = Bind(data_load); |
3499 LoadFieldInstr* length_load = new(Z) LoadFieldInstr( | 3499 LoadFieldInstr* length_load = new(Z) LoadFieldInstr( |
3500 data, | 3500 data, |
3501 Array::length_offset(), | 3501 Array::length_offset(), |
3502 Type::ZoneHandle(Z, Type::SmiType()), | 3502 Type::ZoneHandle(Z, Type::SmiType()), |
3503 node->token_pos()); | 3503 node->token_pos()); |
3504 length_load->set_result_cid(kSmiCid); | 3504 length_load->set_result_cid(kSmiCid); |
3505 length_load->set_recognized_kind(MethodRecognizer::kObjectArrayLength); | 3505 length_load->set_recognized_kind(MethodRecognizer::kObjectArrayLength); |
3506 return ReturnDefinition(length_load); | 3506 return ReturnDefinition(length_load); |
3507 } | 3507 } |
3508 case MethodRecognizer::kObjectArrayAllocate: { | 3508 case MethodRecognizer::kObjectArrayAllocate: { |
3509 LocalVariable* type_args_parameter = | 3509 LocalVariable* type_args_parameter = |
3510 node->scope()->LookupVariable(Symbols::TypeArgumentsParameter(), | 3510 node->scope()->LookupVariable(Symbols::TypeArgumentsParameter(), |
3511 true); | 3511 true); |
3512 Value* element_type = Bind(new(Z) LoadLocalInstr(*type_args_parameter)); | 3512 Value* element_type = Bind(new(Z) LoadLocalInstr(*type_args_parameter)); |
3513 LocalVariable* length_parameter = | 3513 LocalVariable* length_parameter = |
3514 node->scope()->LookupVariable(Symbols::Length(), true); | 3514 node->scope()->LookupVariable(Symbols::Length(), true); |
3515 Value* length = Bind(new(Z) LoadLocalInstr(*length_parameter)); | 3515 Value* length = Bind(new(Z) LoadLocalInstr(*length_parameter)); |
3516 CreateArrayInstr* create_array = | 3516 CreateArrayInstr* create_array = |
3517 new CreateArrayInstr(node->token_pos(), element_type, length); | 3517 new CreateArrayInstr(node->token_pos(), element_type, length); |
3518 return ReturnDefinition(create_array); | 3518 return ReturnDefinition(create_array); |
3519 } | 3519 } |
3520 case MethodRecognizer::kBigint_getDigits: { | 3520 case MethodRecognizer::kBigint_getDigits: { |
3521 return ReturnDefinition(BuildNativeGetter( | 3521 return ReturnDefinition(BuildNativeGetter( |
3522 node, kind, Bigint::digits_offset(), | 3522 node, kind, Bigint::digits_offset(), |
3523 Type::ZoneHandle(Z, Type::DynamicType()), | 3523 Object::dynamic_type(), |
3524 kTypedDataUint32ArrayCid)); | 3524 kTypedDataUint32ArrayCid)); |
3525 } | 3525 } |
3526 case MethodRecognizer::kBigint_getUsed: { | 3526 case MethodRecognizer::kBigint_getUsed: { |
3527 return ReturnDefinition(BuildNativeGetter( | 3527 return ReturnDefinition(BuildNativeGetter( |
3528 node, kind, Bigint::used_offset(), | 3528 node, kind, Bigint::used_offset(), |
3529 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid)); | 3529 Type::ZoneHandle(Z, Type::SmiType()), kSmiCid)); |
3530 } | 3530 } |
3531 case MethodRecognizer::kLinkedHashMap_getIndex: { | 3531 case MethodRecognizer::kLinkedHashMap_getIndex: { |
3532 return ReturnDefinition(BuildNativeGetter( | 3532 return ReturnDefinition(BuildNativeGetter( |
3533 node, kind, LinkedHashMap::index_offset(), | 3533 node, kind, LinkedHashMap::index_offset(), |
3534 Type::ZoneHandle(Z, Type::DynamicType()), | 3534 Object::dynamic_type(), |
3535 kDynamicCid)); | 3535 kDynamicCid)); |
3536 } | 3536 } |
3537 case MethodRecognizer::kLinkedHashMap_setIndex: { | 3537 case MethodRecognizer::kLinkedHashMap_setIndex: { |
3538 return ReturnDefinition(DoNativeSetterStoreValue( | 3538 return ReturnDefinition(DoNativeSetterStoreValue( |
3539 node, LinkedHashMap::index_offset(), kEmitStoreBarrier)); | 3539 node, LinkedHashMap::index_offset(), kEmitStoreBarrier)); |
3540 } | 3540 } |
3541 case MethodRecognizer::kLinkedHashMap_getData: { | 3541 case MethodRecognizer::kLinkedHashMap_getData: { |
3542 return ReturnDefinition(BuildNativeGetter( | 3542 return ReturnDefinition(BuildNativeGetter( |
3543 node, kind, LinkedHashMap::data_offset(), | 3543 node, kind, LinkedHashMap::data_offset(), |
3544 Type::ZoneHandle(Z, Type::DynamicType()), | 3544 Object::dynamic_type(), |
3545 kArrayCid)); | 3545 kArrayCid)); |
3546 } | 3546 } |
3547 case MethodRecognizer::kLinkedHashMap_setData: { | 3547 case MethodRecognizer::kLinkedHashMap_setData: { |
3548 return ReturnDefinition(DoNativeSetterStoreValue( | 3548 return ReturnDefinition(DoNativeSetterStoreValue( |
3549 node, LinkedHashMap::data_offset(), kEmitStoreBarrier)); | 3549 node, LinkedHashMap::data_offset(), kEmitStoreBarrier)); |
3550 } | 3550 } |
3551 case MethodRecognizer::kLinkedHashMap_getHashMask: { | 3551 case MethodRecognizer::kLinkedHashMap_getHashMask: { |
3552 return ReturnDefinition(BuildNativeGetter( | 3552 return ReturnDefinition(BuildNativeGetter( |
3553 node, kind, LinkedHashMap::hash_mask_offset(), | 3553 node, kind, LinkedHashMap::hash_mask_offset(), |
3554 Type::ZoneHandle(Z, Type::SmiType()), | 3554 Type::ZoneHandle(Z, Type::SmiType()), |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4023 (kParamEndSlotFromFp + num_params) : kFirstLocalSlotFromFp; | 4023 (kParamEndSlotFromFp + num_params) : kFirstLocalSlotFromFp; |
4024 for (int pos = 0; pos < num_params; param_frame_index--, pos++) { | 4024 for (int pos = 0; pos < num_params; param_frame_index--, pos++) { |
4025 const LocalVariable& parameter = *scope->VariableAt(pos); | 4025 const LocalVariable& parameter = *scope->VariableAt(pos); |
4026 ASSERT(parameter.owner() == scope); | 4026 ASSERT(parameter.owner() == scope); |
4027 if (parameter.is_captured()) { | 4027 if (parameter.is_captured()) { |
4028 // Create a temporary local describing the original position. | 4028 // Create a temporary local describing the original position. |
4029 const String& temp_name = Symbols::TempParam(); | 4029 const String& temp_name = Symbols::TempParam(); |
4030 LocalVariable* temp_local = new(Z) LocalVariable( | 4030 LocalVariable* temp_local = new(Z) LocalVariable( |
4031 0, // Token index. | 4031 0, // Token index. |
4032 temp_name, | 4032 temp_name, |
4033 Type::ZoneHandle(Z, Type::DynamicType())); // Type. | 4033 Object::dynamic_type()); // Type. |
4034 temp_local->set_index(param_frame_index); | 4034 temp_local->set_index(param_frame_index); |
4035 | 4035 |
4036 // Mark this local as captured parameter so that the optimizer | 4036 // Mark this local as captured parameter so that the optimizer |
4037 // correctly handles these when compiling try-catch: Captured | 4037 // correctly handles these when compiling try-catch: Captured |
4038 // parameters are not in the stack environment, therefore they | 4038 // parameters are not in the stack environment, therefore they |
4039 // must be skipped when emitting sync-code in try-blocks. | 4039 // must be skipped when emitting sync-code in try-blocks. |
4040 temp_local->set_is_captured_parameter(true); | 4040 temp_local->set_is_captured_parameter(true); |
4041 | 4041 |
4042 // Copy parameter from local frame to current context. | 4042 // Copy parameter from local frame to current context. |
4043 Value* load = Bind(BuildLoadLocal(*temp_local)); | 4043 Value* load = Bind(BuildLoadLocal(*temp_local)); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4332 Value* stacktrace = for_finally.Bind( | 4332 Value* stacktrace = for_finally.Bind( |
4333 for_finally.BuildLoadLocal(catch_block->rethrow_stacktrace_var())); | 4333 for_finally.BuildLoadLocal(catch_block->rethrow_stacktrace_var())); |
4334 for_finally.PushArgument(stacktrace); | 4334 for_finally.PushArgument(stacktrace); |
4335 for_finally.AddInstruction( | 4335 for_finally.AddInstruction( |
4336 new(Z) ReThrowInstr(catch_block->token_pos(), catch_handler_index)); | 4336 new(Z) ReThrowInstr(catch_block->token_pos(), catch_handler_index)); |
4337 for_finally.CloseFragment(); | 4337 for_finally.CloseFragment(); |
4338 } | 4338 } |
4339 ASSERT(!for_finally.is_open()); | 4339 ASSERT(!for_finally.is_open()); |
4340 | 4340 |
4341 const Array& types = Array::ZoneHandle(Z, Array::New(1, Heap::kOld)); | 4341 const Array& types = Array::ZoneHandle(Z, Array::New(1, Heap::kOld)); |
4342 types.SetAt(0, Type::Handle(Z, Type::DynamicType())); | 4342 types.SetAt(0, Object::dynamic_type()); |
4343 CatchBlockEntryInstr* finally_entry = | 4343 CatchBlockEntryInstr* finally_entry = |
4344 new(Z) CatchBlockEntryInstr(owner()->AllocateBlockId(), | 4344 new(Z) CatchBlockEntryInstr(owner()->AllocateBlockId(), |
4345 original_handler_index, | 4345 original_handler_index, |
4346 types, | 4346 types, |
4347 catch_handler_index, | 4347 catch_handler_index, |
4348 catch_block->exception_var(), | 4348 catch_block->exception_var(), |
4349 catch_block->stacktrace_var(), | 4349 catch_block->stacktrace_var(), |
4350 catch_block->needs_stacktrace()); | 4350 catch_block->needs_stacktrace()); |
4351 owner()->AddCatchEntry(finally_entry); | 4351 owner()->AddCatchEntry(finally_entry); |
4352 AppendFragment(finally_entry, for_finally); | 4352 AppendFragment(finally_entry, for_finally); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4606 Report::MessageF(Report::kBailout, | 4606 Report::MessageF(Report::kBailout, |
4607 Script::Handle(function.script()), | 4607 Script::Handle(function.script()), |
4608 function.token_pos(), | 4608 function.token_pos(), |
4609 "FlowGraphBuilder Bailout: %s %s", | 4609 "FlowGraphBuilder Bailout: %s %s", |
4610 String::Handle(function.name()).ToCString(), | 4610 String::Handle(function.name()).ToCString(), |
4611 reason); | 4611 reason); |
4612 UNREACHABLE(); | 4612 UNREACHABLE(); |
4613 } | 4613 } |
4614 | 4614 |
4615 } // namespace dart | 4615 } // namespace dart |
OLD | NEW |