OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "vm/kernel_to_il.h" | 7 #include "vm/kernel_to_il.h" |
8 | 8 |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/intermediate_language.h" | 10 #include "vm/intermediate_language.h" |
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 | 2010 |
2011 | 2011 |
2012 FlowGraphBuilder::FlowGraphBuilder( | 2012 FlowGraphBuilder::FlowGraphBuilder( |
2013 TreeNode* node, | 2013 TreeNode* node, |
2014 ParsedFunction* parsed_function, | 2014 ParsedFunction* parsed_function, |
2015 const ZoneGrowableArray<const ICData*>& ic_data_array, | 2015 const ZoneGrowableArray<const ICData*>& ic_data_array, |
2016 InlineExitCollector* exit_collector, | 2016 InlineExitCollector* exit_collector, |
2017 intptr_t osr_id, | 2017 intptr_t osr_id, |
2018 intptr_t first_block_id) | 2018 intptr_t first_block_id) |
2019 : translation_helper_(Thread::Current()), | 2019 : translation_helper_(Thread::Current()), |
2020 thread_(translation_helper_.thread()), | |
2021 zone_(translation_helper_.zone()), | 2020 zone_(translation_helper_.zone()), |
2022 node_(node), | 2021 node_(node), |
2023 parsed_function_(parsed_function), | 2022 parsed_function_(parsed_function), |
2024 osr_id_(osr_id), | 2023 osr_id_(osr_id), |
2025 ic_data_array_(ic_data_array), | 2024 ic_data_array_(ic_data_array), |
2026 exit_collector_(exit_collector), | 2025 exit_collector_(exit_collector), |
2027 next_block_id_(first_block_id), | 2026 next_block_id_(first_block_id), |
2028 next_function_id_(0), | 2027 next_function_id_(0), |
2029 context_depth_(0), | 2028 context_depth_(0), |
2030 loop_depth_(0), | 2029 loop_depth_(0), |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2242 | 2241 |
2243 Fragment FlowGraphBuilder::LoadFunctionTypeArguments() { | 2242 Fragment FlowGraphBuilder::LoadFunctionTypeArguments() { |
2244 UNIMPLEMENTED(); // TODO(regis) | 2243 UNIMPLEMENTED(); // TODO(regis) |
2245 return Fragment(NULL); | 2244 return Fragment(NULL); |
2246 } | 2245 } |
2247 | 2246 |
2248 | 2247 |
2249 Fragment FlowGraphBuilder::InstantiateType(const AbstractType& type) { | 2248 Fragment FlowGraphBuilder::InstantiateType(const AbstractType& type) { |
2250 Value* function_type_args = Pop(); | 2249 Value* function_type_args = Pop(); |
2251 Value* instantiator_type_args = Pop(); | 2250 Value* instantiator_type_args = Pop(); |
2252 InstantiateTypeInstr* instr = new (Z) InstantiateTypeInstr( | 2251 InstantiateTypeInstr* instr = |
2253 TokenPosition::kNoSource, type, instantiator_type_args, | 2252 new (Z) InstantiateTypeInstr(TokenPosition::kNoSource, type, |
2254 function_type_args, GetNextDeoptId()); | 2253 instantiator_type_args, function_type_args); |
2255 Push(instr); | 2254 Push(instr); |
2256 return Fragment(instr); | 2255 return Fragment(instr); |
2257 } | 2256 } |
2258 | 2257 |
2259 | 2258 |
2260 Fragment FlowGraphBuilder::InstantiateTypeArguments( | 2259 Fragment FlowGraphBuilder::InstantiateTypeArguments( |
2261 const TypeArguments& type_arguments) { | 2260 const TypeArguments& type_arguments) { |
2262 Value* function_type_args = Pop(); | 2261 Value* function_type_args = Pop(); |
2263 Value* instantiator_type_args = Pop(); | 2262 Value* instantiator_type_args = Pop(); |
2264 InstantiateTypeArgumentsInstr* instr = new (Z) InstantiateTypeArgumentsInstr( | 2263 InstantiateTypeArgumentsInstr* instr = new (Z) InstantiateTypeArgumentsInstr( |
2265 TokenPosition::kNoSource, type_arguments, *active_class_.klass, | 2264 TokenPosition::kNoSource, type_arguments, *active_class_.klass, |
2266 instantiator_type_args, function_type_args, GetNextDeoptId()); | 2265 instantiator_type_args, function_type_args); |
2267 Push(instr); | 2266 Push(instr); |
2268 return Fragment(instr); | 2267 return Fragment(instr); |
2269 } | 2268 } |
2270 | 2269 |
2271 | 2270 |
2272 Fragment FlowGraphBuilder::TranslateInstantiatedTypeArguments( | 2271 Fragment FlowGraphBuilder::TranslateInstantiatedTypeArguments( |
2273 const TypeArguments& type_arguments) { | 2272 const TypeArguments& type_arguments) { |
2274 Fragment instructions; | 2273 Fragment instructions; |
2275 | 2274 |
2276 if (type_arguments.IsNull() || type_arguments.IsInstantiated()) { | 2275 if (type_arguments.IsNull() || type_arguments.IsInstantiated()) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 BooleanNegateInstr* negate = new (Z) BooleanNegateInstr(Pop()); | 2345 BooleanNegateInstr* negate = new (Z) BooleanNegateInstr(Pop()); |
2347 Push(negate); | 2346 Push(negate); |
2348 return Fragment(negate); | 2347 return Fragment(negate); |
2349 } | 2348 } |
2350 | 2349 |
2351 | 2350 |
2352 Fragment FlowGraphBuilder::StrictCompare(Token::Kind kind, | 2351 Fragment FlowGraphBuilder::StrictCompare(Token::Kind kind, |
2353 bool number_check /* = false */) { | 2352 bool number_check /* = false */) { |
2354 Value* right = Pop(); | 2353 Value* right = Pop(); |
2355 Value* left = Pop(); | 2354 Value* left = Pop(); |
2356 StrictCompareInstr* compare = | 2355 StrictCompareInstr* compare = new (Z) StrictCompareInstr( |
2357 new (Z) StrictCompareInstr(TokenPosition::kNoSource, kind, left, right, | 2356 TokenPosition::kNoSource, kind, left, right, number_check); |
2358 number_check, GetNextDeoptId()); | |
2359 Push(compare); | 2357 Push(compare); |
2360 return Fragment(compare); | 2358 return Fragment(compare); |
2361 } | 2359 } |
2362 | 2360 |
2363 | 2361 |
2364 Fragment FlowGraphBuilder::BranchIfTrue(TargetEntryInstr** then_entry, | 2362 Fragment FlowGraphBuilder::BranchIfTrue(TargetEntryInstr** then_entry, |
2365 TargetEntryInstr** otherwise_entry, | 2363 TargetEntryInstr** otherwise_entry, |
2366 bool negate) { | 2364 bool negate) { |
2367 Fragment instructions = Constant(Bool::True()); | 2365 Fragment instructions = Constant(Bool::True()); |
2368 return instructions + BranchIfEqual(then_entry, otherwise_entry, negate); | 2366 return instructions + BranchIfEqual(then_entry, otherwise_entry, negate); |
2369 } | 2367 } |
2370 | 2368 |
2371 | 2369 |
2372 Fragment FlowGraphBuilder::BranchIfNull(TargetEntryInstr** then_entry, | 2370 Fragment FlowGraphBuilder::BranchIfNull(TargetEntryInstr** then_entry, |
2373 TargetEntryInstr** otherwise_entry, | 2371 TargetEntryInstr** otherwise_entry, |
2374 bool negate) { | 2372 bool negate) { |
2375 Fragment instructions = NullConstant(); | 2373 Fragment instructions = NullConstant(); |
2376 return instructions + BranchIfEqual(then_entry, otherwise_entry, negate); | 2374 return instructions + BranchIfEqual(then_entry, otherwise_entry, negate); |
2377 } | 2375 } |
2378 | 2376 |
2379 Fragment FlowGraphBuilder::BranchIfEqual(TargetEntryInstr** then_entry, | 2377 Fragment FlowGraphBuilder::BranchIfEqual(TargetEntryInstr** then_entry, |
2380 TargetEntryInstr** otherwise_entry, | 2378 TargetEntryInstr** otherwise_entry, |
2381 bool negate) { | 2379 bool negate) { |
2382 Value* right_value = Pop(); | 2380 Value* right_value = Pop(); |
2383 Value* left_value = Pop(); | 2381 Value* left_value = Pop(); |
2384 StrictCompareInstr* compare = new (Z) StrictCompareInstr( | 2382 StrictCompareInstr* compare = new (Z) StrictCompareInstr( |
2385 TokenPosition::kNoSource, negate ? Token::kNE_STRICT : Token::kEQ_STRICT, | 2383 TokenPosition::kNoSource, negate ? Token::kNE_STRICT : Token::kEQ_STRICT, |
2386 left_value, right_value, false, GetNextDeoptId()); | 2384 left_value, right_value, false); |
2387 BranchInstr* branch = new (Z) BranchInstr(compare, GetNextDeoptId()); | 2385 BranchInstr* branch = new (Z) BranchInstr(compare); |
2388 *then_entry = *branch->true_successor_address() = BuildTargetEntry(); | 2386 *then_entry = *branch->true_successor_address() = BuildTargetEntry(); |
2389 *otherwise_entry = *branch->false_successor_address() = BuildTargetEntry(); | 2387 *otherwise_entry = *branch->false_successor_address() = BuildTargetEntry(); |
2390 return Fragment(branch).closed(); | 2388 return Fragment(branch).closed(); |
2391 } | 2389 } |
2392 | 2390 |
2393 | 2391 |
2394 Fragment FlowGraphBuilder::BranchIfStrictEqual( | 2392 Fragment FlowGraphBuilder::BranchIfStrictEqual( |
2395 TargetEntryInstr** then_entry, | 2393 TargetEntryInstr** then_entry, |
2396 TargetEntryInstr** otherwise_entry) { | 2394 TargetEntryInstr** otherwise_entry) { |
2397 Value* rhs = Pop(); | 2395 Value* rhs = Pop(); |
2398 Value* lhs = Pop(); | 2396 Value* lhs = Pop(); |
2399 StrictCompareInstr* compare = | 2397 StrictCompareInstr* compare = new (Z) StrictCompareInstr( |
2400 new (Z) StrictCompareInstr(TokenPosition::kNoSource, Token::kEQ_STRICT, | 2398 TokenPosition::kNoSource, Token::kEQ_STRICT, lhs, rhs, false); |
2401 lhs, rhs, false, GetNextDeoptId()); | 2399 BranchInstr* branch = new (Z) BranchInstr(compare); |
2402 BranchInstr* branch = new (Z) BranchInstr(compare, GetNextDeoptId()); | |
2403 *then_entry = *branch->true_successor_address() = BuildTargetEntry(); | 2400 *then_entry = *branch->true_successor_address() = BuildTargetEntry(); |
2404 *otherwise_entry = *branch->false_successor_address() = BuildTargetEntry(); | 2401 *otherwise_entry = *branch->false_successor_address() = BuildTargetEntry(); |
2405 return Fragment(branch).closed(); | 2402 return Fragment(branch).closed(); |
2406 } | 2403 } |
2407 | 2404 |
2408 | 2405 |
2409 Fragment FlowGraphBuilder::CatchBlockEntry(const Array& handler_types, | 2406 Fragment FlowGraphBuilder::CatchBlockEntry(const Array& handler_types, |
2410 intptr_t handler_index, | 2407 intptr_t handler_index, |
2411 bool needs_stacktrace) { | 2408 bool needs_stacktrace) { |
2412 ASSERT(CurrentException()->is_captured() == | 2409 ASSERT(CurrentException()->is_captured() == |
(...skipping 29 matching lines...) Expand all Loading... |
2442 } | 2439 } |
2443 | 2440 |
2444 | 2441 |
2445 Fragment FlowGraphBuilder::TryCatch(int try_handler_index) { | 2442 Fragment FlowGraphBuilder::TryCatch(int try_handler_index) { |
2446 // The body of the try needs to have it's own block in order to get a new try | 2443 // The body of the try needs to have it's own block in order to get a new try |
2447 // index. | 2444 // index. |
2448 // | 2445 // |
2449 // => We therefore create a block for the body (fresh try index) and another | 2446 // => We therefore create a block for the body (fresh try index) and another |
2450 // join block (with current try index). | 2447 // join block (with current try index). |
2451 Fragment body; | 2448 Fragment body; |
2452 JoinEntryInstr* entry = new (Z) | 2449 JoinEntryInstr* entry = |
2453 JoinEntryInstr(AllocateBlockId(), try_handler_index, GetNextDeoptId()); | 2450 new (Z) JoinEntryInstr(AllocateBlockId(), try_handler_index); |
2454 body += LoadLocal(parsed_function_->current_context_var()); | 2451 body += LoadLocal(parsed_function_->current_context_var()); |
2455 body += StoreLocal(TokenPosition::kNoSource, CurrentCatchContext()); | 2452 body += StoreLocal(TokenPosition::kNoSource, CurrentCatchContext()); |
2456 body += Drop(); | 2453 body += Drop(); |
2457 body += Goto(entry); | 2454 body += Goto(entry); |
2458 return Fragment(body.entry, entry); | 2455 return Fragment(body.entry, entry); |
2459 } | 2456 } |
2460 | 2457 |
2461 | 2458 |
2462 Fragment FlowGraphBuilder::CheckStackOverflowInPrologue() { | 2459 Fragment FlowGraphBuilder::CheckStackOverflowInPrologue() { |
2463 if (IsInlining()) { | 2460 if (IsInlining()) { |
2464 // If we are inlining don't actually attach the stack check. We must still | 2461 // If we are inlining don't actually attach the stack check. We must still |
2465 // create the stack check in order to allocate a deopt id. | 2462 // create the stack check in order to allocate a deopt id. |
2466 CheckStackOverflow(); | 2463 CheckStackOverflow(); |
2467 return Fragment(); | 2464 return Fragment(); |
2468 } | 2465 } |
2469 return CheckStackOverflow(); | 2466 return CheckStackOverflow(); |
2470 } | 2467 } |
2471 | 2468 |
2472 | 2469 |
2473 Fragment FlowGraphBuilder::CheckStackOverflow() { | 2470 Fragment FlowGraphBuilder::CheckStackOverflow() { |
2474 return Fragment(new (Z) CheckStackOverflowInstr( | 2471 return Fragment( |
2475 TokenPosition::kNoSource, loop_depth_, GetNextDeoptId())); | 2472 new (Z) CheckStackOverflowInstr(TokenPosition::kNoSource, loop_depth_)); |
2476 } | 2473 } |
2477 | 2474 |
2478 | 2475 |
2479 Fragment FlowGraphBuilder::CloneContext() { | 2476 Fragment FlowGraphBuilder::CloneContext() { |
2480 LocalVariable* context_variable = parsed_function_->current_context_var(); | 2477 LocalVariable* context_variable = parsed_function_->current_context_var(); |
2481 | 2478 |
2482 Fragment instructions = LoadLocal(context_variable); | 2479 Fragment instructions = LoadLocal(context_variable); |
2483 | 2480 |
2484 CloneContextInstr* clone_instruction = new (Z) | 2481 CloneContextInstr* clone_instruction = |
2485 CloneContextInstr(TokenPosition::kNoSource, Pop(), GetNextDeoptId()); | 2482 new (Z) CloneContextInstr(TokenPosition::kNoSource, Pop()); |
2486 instructions <<= clone_instruction; | 2483 instructions <<= clone_instruction; |
2487 Push(clone_instruction); | 2484 Push(clone_instruction); |
2488 | 2485 |
2489 instructions += StoreLocal(TokenPosition::kNoSource, context_variable); | 2486 instructions += StoreLocal(TokenPosition::kNoSource, context_variable); |
2490 instructions += Drop(); | 2487 instructions += Drop(); |
2491 return instructions; | 2488 return instructions; |
2492 } | 2489 } |
2493 | 2490 |
2494 | 2491 |
2495 Fragment FlowGraphBuilder::Constant(const Object& value) { | 2492 Fragment FlowGraphBuilder::Constant(const Object& value) { |
2496 ASSERT(value.IsNotTemporaryScopedHandle()); | 2493 ASSERT(value.IsNotTemporaryScopedHandle()); |
2497 ConstantInstr* constant = new (Z) ConstantInstr(value); | 2494 ConstantInstr* constant = new (Z) ConstantInstr(value); |
2498 Push(constant); | 2495 Push(constant); |
2499 return Fragment(constant); | 2496 return Fragment(constant); |
2500 } | 2497 } |
2501 | 2498 |
2502 | 2499 |
2503 Fragment FlowGraphBuilder::CreateArray() { | 2500 Fragment FlowGraphBuilder::CreateArray() { |
2504 Value* element_count = Pop(); | 2501 Value* element_count = Pop(); |
2505 CreateArrayInstr* array = | 2502 CreateArrayInstr* array = new (Z) CreateArrayInstr(TokenPosition::kNoSource, |
2506 new (Z) CreateArrayInstr(TokenPosition::kNoSource, | 2503 Pop(), // Element type. |
2507 Pop(), // Element type. | 2504 element_count); |
2508 element_count, GetNextDeoptId()); | |
2509 Push(array); | 2505 Push(array); |
2510 return Fragment(array); | 2506 return Fragment(array); |
2511 } | 2507 } |
2512 | 2508 |
2513 | 2509 |
2514 Fragment FlowGraphBuilder::Goto(JoinEntryInstr* destination) { | 2510 Fragment FlowGraphBuilder::Goto(JoinEntryInstr* destination) { |
2515 return Fragment(new (Z) GotoInstr(destination, GetNextDeoptId())).closed(); | 2511 return Fragment(new (Z) GotoInstr(destination)).closed(); |
2516 } | 2512 } |
2517 | 2513 |
2518 | 2514 |
2519 Fragment FlowGraphBuilder::IntConstant(int64_t value) { | 2515 Fragment FlowGraphBuilder::IntConstant(int64_t value) { |
2520 return Fragment( | 2516 return Fragment( |
2521 Constant(Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld)))); | 2517 Constant(Integer::ZoneHandle(Z, Integer::New(value, Heap::kOld)))); |
2522 } | 2518 } |
2523 | 2519 |
2524 | 2520 |
2525 Fragment FlowGraphBuilder::InstanceCall(TokenPosition position, | 2521 Fragment FlowGraphBuilder::InstanceCall(TokenPosition position, |
2526 const dart::String& name, | 2522 const dart::String& name, |
2527 Token::Kind kind, | 2523 Token::Kind kind, |
2528 intptr_t argument_count, | 2524 intptr_t argument_count, |
2529 intptr_t num_args_checked) { | 2525 intptr_t num_args_checked) { |
2530 return InstanceCall(position, name, kind, argument_count, Array::null_array(), | 2526 return InstanceCall(position, name, kind, argument_count, Array::null_array(), |
2531 num_args_checked); | 2527 num_args_checked); |
2532 } | 2528 } |
2533 | 2529 |
2534 | 2530 |
2535 Fragment FlowGraphBuilder::InstanceCall(TokenPosition position, | 2531 Fragment FlowGraphBuilder::InstanceCall(TokenPosition position, |
2536 const dart::String& name, | 2532 const dart::String& name, |
2537 Token::Kind kind, | 2533 Token::Kind kind, |
2538 intptr_t argument_count, | 2534 intptr_t argument_count, |
2539 const Array& argument_names, | 2535 const Array& argument_names, |
2540 intptr_t num_args_checked) { | 2536 intptr_t num_args_checked) { |
2541 ArgumentArray arguments = GetArguments(argument_count); | 2537 ArgumentArray arguments = GetArguments(argument_count); |
2542 const intptr_t kTypeArgsLen = 0; // Generic instance calls not yet supported. | 2538 const intptr_t kTypeArgsLen = 0; // Generic instance calls not yet supported. |
2543 InstanceCallInstr* call = new (Z) InstanceCallInstr( | 2539 InstanceCallInstr* call = new (Z) |
2544 position, name, kind, arguments, kTypeArgsLen, argument_names, | 2540 InstanceCallInstr(position, name, kind, arguments, kTypeArgsLen, |
2545 num_args_checked, ic_data_array_, GetNextDeoptId()); | 2541 argument_names, num_args_checked, ic_data_array_); |
2546 Push(call); | 2542 Push(call); |
2547 return Fragment(call); | 2543 return Fragment(call); |
2548 } | 2544 } |
2549 | 2545 |
2550 | 2546 |
2551 Fragment FlowGraphBuilder::ClosureCall(int argument_count, | 2547 Fragment FlowGraphBuilder::ClosureCall(int argument_count, |
2552 const Array& argument_names) { | 2548 const Array& argument_names) { |
2553 Value* function = Pop(); | 2549 Value* function = Pop(); |
2554 ArgumentArray arguments = GetArguments(argument_count); | 2550 ArgumentArray arguments = GetArguments(argument_count); |
2555 const intptr_t kTypeArgsLen = 0; // Generic closures not yet supported. | 2551 const intptr_t kTypeArgsLen = 0; // Generic closures not yet supported. |
2556 ClosureCallInstr* call = new (Z) | 2552 ClosureCallInstr* call = |
2557 ClosureCallInstr(function, arguments, kTypeArgsLen, argument_names, | 2553 new (Z) ClosureCallInstr(function, arguments, kTypeArgsLen, |
2558 TokenPosition::kNoSource, GetNextDeoptId()); | 2554 argument_names, TokenPosition::kNoSource); |
2559 Push(call); | 2555 Push(call); |
2560 return Fragment(call); | 2556 return Fragment(call); |
2561 } | 2557 } |
2562 | 2558 |
2563 | 2559 |
2564 Fragment FlowGraphBuilder::ThrowException(TokenPosition position) { | 2560 Fragment FlowGraphBuilder::ThrowException(TokenPosition position) { |
2565 Fragment instructions; | 2561 Fragment instructions; |
2566 instructions += Drop(); | 2562 instructions += Drop(); |
2567 instructions += | 2563 instructions += Fragment(new (Z) ThrowInstr(position)).closed(); |
2568 Fragment(new (Z) ThrowInstr(position, GetNextDeoptId())).closed(); | |
2569 // Use it's side effect of leaving a constant on the stack (does not change | 2564 // Use it's side effect of leaving a constant on the stack (does not change |
2570 // the graph). | 2565 // the graph). |
2571 NullConstant(); | 2566 NullConstant(); |
2572 | 2567 |
2573 pending_argument_count_ -= 1; | 2568 pending_argument_count_ -= 1; |
2574 | 2569 |
2575 return instructions; | 2570 return instructions; |
2576 } | 2571 } |
2577 | 2572 |
2578 | 2573 |
2579 Fragment FlowGraphBuilder::RethrowException(TokenPosition position, | 2574 Fragment FlowGraphBuilder::RethrowException(TokenPosition position, |
2580 int catch_try_index) { | 2575 int catch_try_index) { |
2581 Fragment instructions; | 2576 Fragment instructions; |
2582 instructions += Drop(); | 2577 instructions += Drop(); |
2583 instructions += Drop(); | 2578 instructions += Drop(); |
2584 instructions += Fragment(new (Z) ReThrowInstr(position, catch_try_index, | 2579 instructions += |
2585 GetNextDeoptId())) | 2580 Fragment(new (Z) ReThrowInstr(position, catch_try_index)).closed(); |
2586 .closed(); | |
2587 // Use it's side effect of leaving a constant on the stack (does not change | 2581 // Use it's side effect of leaving a constant on the stack (does not change |
2588 // the graph). | 2582 // the graph). |
2589 NullConstant(); | 2583 NullConstant(); |
2590 | 2584 |
2591 pending_argument_count_ -= 2; | 2585 pending_argument_count_ -= 2; |
2592 | 2586 |
2593 return instructions; | 2587 return instructions; |
2594 } | 2588 } |
2595 | 2589 |
2596 | 2590 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2656 LoadLocalInstr* load = | 2650 LoadLocalInstr* load = |
2657 new (Z) LoadLocalInstr(*variable, TokenPosition::kNoSource); | 2651 new (Z) LoadLocalInstr(*variable, TokenPosition::kNoSource); |
2658 instructions <<= load; | 2652 instructions <<= load; |
2659 Push(load); | 2653 Push(load); |
2660 } | 2654 } |
2661 return instructions; | 2655 return instructions; |
2662 } | 2656 } |
2663 | 2657 |
2664 | 2658 |
2665 Fragment FlowGraphBuilder::InitStaticField(const dart::Field& field) { | 2659 Fragment FlowGraphBuilder::InitStaticField(const dart::Field& field) { |
2666 InitStaticFieldInstr* init = new (Z) | 2660 InitStaticFieldInstr* init = |
2667 InitStaticFieldInstr(Pop(), MayCloneField(Z, field), GetNextDeoptId()); | 2661 new (Z) InitStaticFieldInstr(Pop(), MayCloneField(Z, field)); |
2668 return Fragment(init); | 2662 return Fragment(init); |
2669 } | 2663 } |
2670 | 2664 |
2671 | 2665 |
2672 Fragment FlowGraphBuilder::LoadStaticField() { | 2666 Fragment FlowGraphBuilder::LoadStaticField() { |
2673 LoadStaticFieldInstr* load = | 2667 LoadStaticFieldInstr* load = |
2674 new (Z) LoadStaticFieldInstr(Pop(), TokenPosition::kNoSource); | 2668 new (Z) LoadStaticFieldInstr(Pop(), TokenPosition::kNoSource); |
2675 Push(load); | 2669 Push(load); |
2676 return Fragment(load); | 2670 return Fragment(load); |
2677 } | 2671 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2720 (function.IsAsyncClosure() || function.IsAsyncGenClosure())) { | 2714 (function.IsAsyncClosure() || function.IsAsyncGenClosure())) { |
2721 // We are returning from an asynchronous closure. Before we do that, be | 2715 // We are returning from an asynchronous closure. Before we do that, be |
2722 // sure to clear the thread's asynchronous stack trace. | 2716 // sure to clear the thread's asynchronous stack trace. |
2723 const Function& target = Function::ZoneHandle( | 2717 const Function& target = Function::ZoneHandle( |
2724 Z, I->object_store()->async_clear_thread_stack_trace()); | 2718 Z, I->object_store()->async_clear_thread_stack_trace()); |
2725 ASSERT(!target.IsNull()); | 2719 ASSERT(!target.IsNull()); |
2726 instructions += StaticCall(TokenPosition::kNoSource, target, 0); | 2720 instructions += StaticCall(TokenPosition::kNoSource, target, 0); |
2727 instructions += Drop(); | 2721 instructions += Drop(); |
2728 } | 2722 } |
2729 | 2723 |
2730 ReturnInstr* return_instr = | 2724 ReturnInstr* return_instr = new (Z) ReturnInstr(position, value); |
2731 new (Z) ReturnInstr(position, value, GetNextDeoptId()); | |
2732 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); | 2725 if (exit_collector_ != NULL) exit_collector_->AddExit(return_instr); |
2733 | 2726 |
2734 instructions <<= return_instr; | 2727 instructions <<= return_instr; |
2735 | 2728 |
2736 return instructions.closed(); | 2729 return instructions.closed(); |
2737 } | 2730 } |
2738 | 2731 |
2739 | 2732 |
2740 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, | 2733 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, |
2741 const Function& target, | 2734 const Function& target, |
(...skipping 25 matching lines...) Expand all Loading... |
2767 | 2760 |
2768 | 2761 |
2769 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, | 2762 Fragment FlowGraphBuilder::StaticCall(TokenPosition position, |
2770 const Function& target, | 2763 const Function& target, |
2771 intptr_t argument_count, | 2764 intptr_t argument_count, |
2772 const Array& argument_names) { | 2765 const Array& argument_names) { |
2773 ArgumentArray arguments = GetArguments(argument_count); | 2766 ArgumentArray arguments = GetArguments(argument_count); |
2774 const intptr_t kTypeArgsLen = 0; // Generic static calls not yet supported. | 2767 const intptr_t kTypeArgsLen = 0; // Generic static calls not yet supported. |
2775 StaticCallInstr* call = | 2768 StaticCallInstr* call = |
2776 new (Z) StaticCallInstr(position, target, kTypeArgsLen, argument_names, | 2769 new (Z) StaticCallInstr(position, target, kTypeArgsLen, argument_names, |
2777 arguments, ic_data_array_, GetNextDeoptId()); | 2770 arguments, ic_data_array_); |
2778 const intptr_t list_cid = | 2771 const intptr_t list_cid = |
2779 GetResultCidOfListFactory(Z, target, argument_count); | 2772 GetResultCidOfListFactory(Z, target, argument_count); |
2780 if (list_cid != kDynamicCid) { | 2773 if (list_cid != kDynamicCid) { |
2781 call->set_result_cid(list_cid); | 2774 call->set_result_cid(list_cid); |
2782 call->set_is_known_list_constructor(true); | 2775 call->set_is_known_list_constructor(true); |
2783 } else if (target.recognized_kind() != MethodRecognizer::kUnknown) { | 2776 } else if (target.recognized_kind() != MethodRecognizer::kUnknown) { |
2784 call->set_result_cid(MethodRecognizer::ResultCid(target)); | 2777 call->set_result_cid(MethodRecognizer::ResultCid(target)); |
2785 } | 2778 } |
2786 Push(call); | 2779 Push(call); |
2787 return Fragment(call); | 2780 return Fragment(call); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2881 Fragment FlowGraphBuilder::StoreStaticField(TokenPosition position, | 2874 Fragment FlowGraphBuilder::StoreStaticField(TokenPosition position, |
2882 const dart::Field& field) { | 2875 const dart::Field& field) { |
2883 return Fragment( | 2876 return Fragment( |
2884 new (Z) StoreStaticFieldInstr(MayCloneField(Z, field), Pop(), position)); | 2877 new (Z) StoreStaticFieldInstr(MayCloneField(Z, field), Pop(), position)); |
2885 } | 2878 } |
2886 | 2879 |
2887 | 2880 |
2888 Fragment FlowGraphBuilder::StringInterpolate(TokenPosition position) { | 2881 Fragment FlowGraphBuilder::StringInterpolate(TokenPosition position) { |
2889 Value* array = Pop(); | 2882 Value* array = Pop(); |
2890 StringInterpolateInstr* interpolate = | 2883 StringInterpolateInstr* interpolate = |
2891 new (Z) StringInterpolateInstr(array, position, GetNextDeoptId()); | 2884 new (Z) StringInterpolateInstr(array, position); |
2892 Push(interpolate); | 2885 Push(interpolate); |
2893 return Fragment(interpolate); | 2886 return Fragment(interpolate); |
2894 } | 2887 } |
2895 | 2888 |
2896 | 2889 |
2897 Fragment FlowGraphBuilder::StringInterpolateSingle(TokenPosition position) { | 2890 Fragment FlowGraphBuilder::StringInterpolateSingle(TokenPosition position) { |
2898 const int kTypeArgsLen = 0; | 2891 const int kTypeArgsLen = 0; |
2899 const int kNumberOfArguments = 1; | 2892 const int kNumberOfArguments = 1; |
2900 const Array& kNoArgumentNames = Object::null_array(); | 2893 const Array& kNoArgumentNames = Object::null_array(); |
2901 const dart::Class& cls = dart::Class::Handle( | 2894 const dart::Class& cls = dart::Class::Handle( |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3931 instructions += LoadLocal(top_of_stack); | 3924 instructions += LoadLocal(top_of_stack); |
3932 instructions += AssertAssignable(dst_type, dst_name); | 3925 instructions += AssertAssignable(dst_type, dst_name); |
3933 instructions += Drop(); | 3926 instructions += Drop(); |
3934 } | 3927 } |
3935 return instructions; | 3928 return instructions; |
3936 } | 3929 } |
3937 | 3930 |
3938 | 3931 |
3939 Fragment FlowGraphBuilder::AssertBool() { | 3932 Fragment FlowGraphBuilder::AssertBool() { |
3940 Value* value = Pop(); | 3933 Value* value = Pop(); |
3941 AssertBooleanInstr* instr = new (Z) | 3934 AssertBooleanInstr* instr = |
3942 AssertBooleanInstr(TokenPosition::kNoSource, value, GetNextDeoptId()); | 3935 new (Z) AssertBooleanInstr(TokenPosition::kNoSource, value); |
3943 Push(instr); | 3936 Push(instr); |
3944 return Fragment(instr); | 3937 return Fragment(instr); |
3945 } | 3938 } |
3946 | 3939 |
3947 | 3940 |
3948 Fragment FlowGraphBuilder::AssertAssignable(const AbstractType& dst_type, | 3941 Fragment FlowGraphBuilder::AssertAssignable(const AbstractType& dst_type, |
3949 const dart::String& dst_name) { | 3942 const dart::String& dst_name) { |
3950 Fragment instructions; | 3943 Fragment instructions; |
3951 Value* value = Pop(); | 3944 Value* value = Pop(); |
3952 | 3945 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4271 } | 4264 } |
4272 default_values->Add(default_value); | 4265 default_values->Add(default_value); |
4273 } | 4266 } |
4274 } | 4267 } |
4275 parsed_function_->set_default_parameter_values(default_values); | 4268 parsed_function_->set_default_parameter_values(default_values); |
4276 } | 4269 } |
4277 } | 4270 } |
4278 | 4271 |
4279 | 4272 |
4280 TargetEntryInstr* FlowGraphBuilder::BuildTargetEntry() { | 4273 TargetEntryInstr* FlowGraphBuilder::BuildTargetEntry() { |
4281 return new (Z) | 4274 return new (Z) TargetEntryInstr(AllocateBlockId(), CurrentTryIndex()); |
4282 TargetEntryInstr(AllocateBlockId(), CurrentTryIndex(), GetNextDeoptId()); | |
4283 } | 4275 } |
4284 | 4276 |
4285 | 4277 |
4286 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry(intptr_t try_index) { | 4278 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry(intptr_t try_index) { |
4287 return new (Z) JoinEntryInstr(AllocateBlockId(), try_index, GetNextDeoptId()); | 4279 return new (Z) JoinEntryInstr(AllocateBlockId(), try_index); |
4288 } | 4280 } |
4289 | 4281 |
4290 | 4282 |
4291 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry() { | 4283 JoinEntryInstr* FlowGraphBuilder::BuildJoinEntry() { |
4292 return new (Z) | 4284 return new (Z) JoinEntryInstr(AllocateBlockId(), CurrentTryIndex()); |
4293 JoinEntryInstr(AllocateBlockId(), CurrentTryIndex(), GetNextDeoptId()); | |
4294 } | 4285 } |
4295 | 4286 |
4296 | 4287 |
4297 Fragment FlowGraphBuilder::TranslateFieldInitializer(NameIndex canonical_name, | 4288 Fragment FlowGraphBuilder::TranslateFieldInitializer(NameIndex canonical_name, |
4298 Expression* init) { | 4289 Expression* init) { |
4299 dart::Field& field = | 4290 dart::Field& field = |
4300 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(canonical_name)); | 4291 dart::Field::ZoneHandle(Z, H.LookupFieldByKernelField(canonical_name)); |
4301 if (init->IsNullLiteral()) { | 4292 if (init->IsNullLiteral()) { |
4302 field.RecordStore(Object::null_object()); | 4293 field.RecordStore(Object::null_object()); |
4303 return Fragment(); | 4294 return Fragment(); |
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5871 body += TranslateStatement(node->body()); | 5862 body += TranslateStatement(node->body()); |
5872 | 5863 |
5873 Instruction* entry; | 5864 Instruction* entry; |
5874 if (body.is_open()) { | 5865 if (body.is_open()) { |
5875 JoinEntryInstr* join = BuildJoinEntry(); | 5866 JoinEntryInstr* join = BuildJoinEntry(); |
5876 body += Goto(join); | 5867 body += Goto(join); |
5877 | 5868 |
5878 Fragment loop(join); | 5869 Fragment loop(join); |
5879 loop += CheckStackOverflow(); | 5870 loop += CheckStackOverflow(); |
5880 loop += condition; | 5871 loop += condition; |
5881 entry = new (Z) GotoInstr(join, GetNextDeoptId()); | 5872 entry = new (Z) GotoInstr(join); |
5882 } else { | 5873 } else { |
5883 entry = condition.entry; | 5874 entry = condition.entry; |
5884 } | 5875 } |
5885 | 5876 |
5886 | 5877 |
5887 fragment_ = Fragment(entry, loop_exit); | 5878 fragment_ = Fragment(entry, loop_exit); |
5888 --loop_depth_; | 5879 --loop_depth_; |
5889 } | 5880 } |
5890 | 5881 |
5891 | 5882 |
(...skipping 15 matching lines...) Expand all Loading... |
5907 loop += CheckStackOverflow(); | 5898 loop += CheckStackOverflow(); |
5908 loop += body; | 5899 loop += body; |
5909 loop += TranslateCondition(node->condition(), &negate); | 5900 loop += TranslateCondition(node->condition(), &negate); |
5910 TargetEntryInstr* loop_repeat; | 5901 TargetEntryInstr* loop_repeat; |
5911 TargetEntryInstr* loop_exit; | 5902 TargetEntryInstr* loop_exit; |
5912 loop += BranchIfTrue(&loop_repeat, &loop_exit, negate); | 5903 loop += BranchIfTrue(&loop_repeat, &loop_exit, negate); |
5913 | 5904 |
5914 Fragment repeat(loop_repeat); | 5905 Fragment repeat(loop_repeat); |
5915 repeat += Goto(join); | 5906 repeat += Goto(join); |
5916 | 5907 |
5917 fragment_ = Fragment(new (Z) GotoInstr(join, GetNextDeoptId()), loop_exit); | 5908 fragment_ = Fragment(new (Z) GotoInstr(join), loop_exit); |
5918 --loop_depth_; | 5909 --loop_depth_; |
5919 } | 5910 } |
5920 | 5911 |
5921 | 5912 |
5922 void FlowGraphBuilder::VisitForStatement(ForStatement* node) { | 5913 void FlowGraphBuilder::VisitForStatement(ForStatement* node) { |
5923 STREAM_STATEMENT_IF_POSSIBLE(node); | 5914 STREAM_STATEMENT_IF_POSSIBLE(node); |
5924 | 5915 |
5925 Fragment declarations; | 5916 Fragment declarations; |
5926 | 5917 |
5927 bool new_context = false; | 5918 bool new_context = false; |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6839 thread->clear_sticky_error(); | 6830 thread->clear_sticky_error(); |
6840 return error.raw(); | 6831 return error.raw(); |
6841 } | 6832 } |
6842 } | 6833 } |
6843 | 6834 |
6844 | 6835 |
6845 } // namespace kernel | 6836 } // namespace kernel |
6846 } // namespace dart | 6837 } // namespace dart |
6847 | 6838 |
6848 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 6839 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |