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 <map> | 5 #include <map> |
6 #include <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "vm/kernel_to_il.h" | 9 #include "vm/kernel_to_il.h" |
10 | 10 |
(...skipping 2342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2353 } | 2353 } |
2354 | 2354 |
2355 | 2355 |
2356 Fragment FlowGraphBuilder::LoadClassId() { | 2356 Fragment FlowGraphBuilder::LoadClassId() { |
2357 LoadClassIdInstr* load = new (Z) LoadClassIdInstr(Pop()); | 2357 LoadClassIdInstr* load = new (Z) LoadClassIdInstr(Pop()); |
2358 Push(load); | 2358 Push(load); |
2359 return Fragment(load); | 2359 return Fragment(load); |
2360 } | 2360 } |
2361 | 2361 |
2362 | 2362 |
| 2363 const dart::Field& MayCloneField(Zone* zone, const dart::Field& field) { |
| 2364 if ((Compiler::IsBackgroundCompilation() || |
| 2365 FLAG_force_clone_compiler_objects) && |
| 2366 field.IsOriginal()) { |
| 2367 return dart::Field::ZoneHandle(zone, field.CloneFromOriginal()); |
| 2368 } else { |
| 2369 ASSERT(field.IsZoneHandle()); |
| 2370 return field; |
| 2371 } |
| 2372 } |
| 2373 |
| 2374 |
2363 Fragment FlowGraphBuilder::LoadField(const dart::Field& field) { | 2375 Fragment FlowGraphBuilder::LoadField(const dart::Field& field) { |
2364 LoadFieldInstr* load = new (Z) | 2376 LoadFieldInstr* load = new (Z) LoadFieldInstr( |
2365 LoadFieldInstr(Pop(), &field, AbstractType::ZoneHandle(Z, field.type()), | 2377 Pop(), &MayCloneField(Z, field), |
2366 TokenPosition::kNoSource); | 2378 AbstractType::ZoneHandle(Z, field.type()), TokenPosition::kNoSource); |
2367 Push(load); | 2379 Push(load); |
2368 return Fragment(load); | 2380 return Fragment(load); |
2369 } | 2381 } |
2370 | 2382 |
2371 | 2383 |
2372 Fragment FlowGraphBuilder::LoadField(intptr_t offset, intptr_t class_id) { | 2384 Fragment FlowGraphBuilder::LoadField(intptr_t offset, intptr_t class_id) { |
2373 LoadFieldInstr* load = new (Z) LoadFieldInstr( | 2385 LoadFieldInstr* load = new (Z) LoadFieldInstr( |
2374 Pop(), offset, AbstractType::ZoneHandle(Z), TokenPosition::kNoSource); | 2386 Pop(), offset, AbstractType::ZoneHandle(Z), TokenPosition::kNoSource); |
2375 load->set_result_cid(class_id); | 2387 load->set_result_cid(class_id); |
2376 Push(load); | 2388 Push(load); |
(...skipping 25 matching lines...) Expand all Loading... |
2402 LoadLocalInstr* load = | 2414 LoadLocalInstr* load = |
2403 new (Z) LoadLocalInstr(*variable, TokenPosition::kNoSource); | 2415 new (Z) LoadLocalInstr(*variable, TokenPosition::kNoSource); |
2404 instructions <<= load; | 2416 instructions <<= load; |
2405 Push(load); | 2417 Push(load); |
2406 } | 2418 } |
2407 return instructions; | 2419 return instructions; |
2408 } | 2420 } |
2409 | 2421 |
2410 | 2422 |
2411 Fragment FlowGraphBuilder::InitStaticField(const dart::Field& field) { | 2423 Fragment FlowGraphBuilder::InitStaticField(const dart::Field& field) { |
2412 InitStaticFieldInstr* init = new (Z) InitStaticFieldInstr(Pop(), field); | 2424 InitStaticFieldInstr* init = |
| 2425 new (Z) InitStaticFieldInstr(Pop(), MayCloneField(Z, field)); |
2413 return Fragment(init); | 2426 return Fragment(init); |
2414 } | 2427 } |
2415 | 2428 |
2416 | 2429 |
2417 Fragment FlowGraphBuilder::LoadStaticField() { | 2430 Fragment FlowGraphBuilder::LoadStaticField() { |
2418 LoadStaticFieldInstr* load = | 2431 LoadStaticFieldInstr* load = |
2419 new (Z) LoadStaticFieldInstr(Pop(), TokenPosition::kNoSource); | 2432 new (Z) LoadStaticFieldInstr(Pop(), TokenPosition::kNoSource); |
2420 Push(load); | 2433 Push(load); |
2421 return Fragment(load); | 2434 return Fragment(load); |
2422 } | 2435 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2520 } | 2533 } |
2521 | 2534 |
2522 | 2535 |
2523 Fragment FlowGraphBuilder::StoreInstanceField( | 2536 Fragment FlowGraphBuilder::StoreInstanceField( |
2524 const dart::Field& field, | 2537 const dart::Field& field, |
2525 StoreBarrierType emit_store_barrier) { | 2538 StoreBarrierType emit_store_barrier) { |
2526 Value* value = Pop(); | 2539 Value* value = Pop(); |
2527 if (value->BindsToConstant()) { | 2540 if (value->BindsToConstant()) { |
2528 emit_store_barrier = kNoStoreBarrier; | 2541 emit_store_barrier = kNoStoreBarrier; |
2529 } | 2542 } |
2530 StoreInstanceFieldInstr* store = new (Z) StoreInstanceFieldInstr( | 2543 StoreInstanceFieldInstr* store = new (Z) |
2531 field, Pop(), value, emit_store_barrier, TokenPosition::kNoSource); | 2544 StoreInstanceFieldInstr(MayCloneField(Z, field), Pop(), value, |
| 2545 emit_store_barrier, TokenPosition::kNoSource); |
2532 return Fragment(store); | 2546 return Fragment(store); |
2533 } | 2547 } |
2534 | 2548 |
2535 | 2549 |
2536 Fragment FlowGraphBuilder::StoreInstanceFieldGuarded(const dart::Field& field) { | 2550 Fragment FlowGraphBuilder::StoreInstanceFieldGuarded(const dart::Field& field) { |
2537 Fragment instructions; | 2551 Fragment instructions; |
| 2552 const dart::Field& field_clone = MayCloneField(Z, field); |
2538 if (FLAG_use_field_guards) { | 2553 if (FLAG_use_field_guards) { |
2539 LocalVariable* store_expression = MakeTemporary(); | 2554 LocalVariable* store_expression = MakeTemporary(); |
2540 instructions += LoadLocal(store_expression); | 2555 instructions += LoadLocal(store_expression); |
2541 instructions += GuardFieldClass(field, Thread::Current()->GetNextDeoptId()); | 2556 instructions += |
| 2557 GuardFieldClass(field_clone, Thread::Current()->GetNextDeoptId()); |
2542 instructions += LoadLocal(store_expression); | 2558 instructions += LoadLocal(store_expression); |
2543 instructions += | 2559 instructions += |
2544 GuardFieldLength(field, Thread::Current()->GetNextDeoptId()); | 2560 GuardFieldLength(field_clone, Thread::Current()->GetNextDeoptId()); |
2545 } | 2561 } |
2546 instructions += StoreInstanceField(field); | 2562 instructions += StoreInstanceField(field_clone); |
2547 return instructions; | 2563 return instructions; |
2548 } | 2564 } |
2549 | 2565 |
2550 | 2566 |
2551 Fragment FlowGraphBuilder::StoreInstanceField( | 2567 Fragment FlowGraphBuilder::StoreInstanceField( |
2552 intptr_t offset, | 2568 intptr_t offset, |
2553 StoreBarrierType emit_store_barrier) { | 2569 StoreBarrierType emit_store_barrier) { |
2554 Value* value = Pop(); | 2570 Value* value = Pop(); |
2555 if (value->BindsToConstant()) { | 2571 if (value->BindsToConstant()) { |
2556 emit_store_barrier = kNoStoreBarrier; | 2572 emit_store_barrier = kNoStoreBarrier; |
(...skipping 16 matching lines...) Expand all Loading... |
2573 StoreLocalInstr* store = | 2589 StoreLocalInstr* store = |
2574 new (Z) StoreLocalInstr(*variable, Pop(), TokenPosition::kNoSource); | 2590 new (Z) StoreLocalInstr(*variable, Pop(), TokenPosition::kNoSource); |
2575 instructions <<= store; | 2591 instructions <<= store; |
2576 Push(store); | 2592 Push(store); |
2577 } | 2593 } |
2578 return instructions; | 2594 return instructions; |
2579 } | 2595 } |
2580 | 2596 |
2581 | 2597 |
2582 Fragment FlowGraphBuilder::StoreStaticField(const dart::Field& field) { | 2598 Fragment FlowGraphBuilder::StoreStaticField(const dart::Field& field) { |
2583 return Fragment( | 2599 return Fragment(new (Z) StoreStaticFieldInstr(MayCloneField(Z, field), Pop(), |
2584 new (Z) StoreStaticFieldInstr(field, Pop(), TokenPosition::kNoSource)); | 2600 TokenPosition::kNoSource)); |
2585 } | 2601 } |
2586 | 2602 |
2587 | 2603 |
2588 Fragment FlowGraphBuilder::StringInterpolate() { | 2604 Fragment FlowGraphBuilder::StringInterpolate() { |
2589 Value* array = Pop(); | 2605 Value* array = Pop(); |
2590 StringInterpolateInstr* interpolate = | 2606 StringInterpolateInstr* interpolate = |
2591 new (Z) StringInterpolateInstr(array, TokenPosition::kNoSource); | 2607 new (Z) StringInterpolateInstr(array, TokenPosition::kNoSource); |
2592 Push(interpolate); | 2608 Push(interpolate); |
2593 return Fragment(interpolate); | 2609 return Fragment(interpolate); |
2594 } | 2610 } |
(...skipping 3167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5762 instructions += LoadLocal(parsed_function_->current_context_var()); | 5778 instructions += LoadLocal(parsed_function_->current_context_var()); |
5763 instructions += StoreInstanceField(Closure::context_offset()); | 5779 instructions += StoreInstanceField(Closure::context_offset()); |
5764 | 5780 |
5765 return instructions; | 5781 return instructions; |
5766 } | 5782 } |
5767 | 5783 |
5768 | 5784 |
5769 } // namespace kernel | 5785 } // namespace kernel |
5770 } // namespace dart | 5786 } // namespace dart |
5771 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 5787 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |