Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: runtime/vm/kernel_to_il.cc

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

Powered by Google App Engine
This is Rietveld 408576698