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

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

Issue 2149023002: VM: Array bounds checks that don't deoptimize for precompiled code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 4 years, 5 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
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/flow_graph_type_propagator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_inliner.h" 5 #include "vm/flow_graph_inliner.h"
6 6
7 #include "vm/aot_optimizer.h" 7 #include "vm/aot_optimizer.h"
8 #include "vm/block_scheduler.h" 8 #include "vm/block_scheduler.h"
9 #include "vm/branch_optimizer.h" 9 #include "vm/branch_optimizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 // Quick access to the current one. 2040 // Quick access to the current one.
2041 #undef Z 2041 #undef Z
2042 #define Z (flow_graph->zone()) 2042 #define Z (flow_graph->zone())
2043 2043
2044 static intptr_t PrepareInlineIndexedOp(FlowGraph* flow_graph, 2044 static intptr_t PrepareInlineIndexedOp(FlowGraph* flow_graph,
2045 Instruction* call, 2045 Instruction* call,
2046 intptr_t array_cid, 2046 intptr_t array_cid,
2047 Definition** array, 2047 Definition** array,
2048 Definition* index, 2048 Definition* index,
2049 Instruction** cursor) { 2049 Instruction** cursor) {
2050 // Insert index smi check.
2051 *cursor = flow_graph->AppendTo(
2052 *cursor,
2053 new(Z) CheckSmiInstr(new(Z) Value(index),
2054 call->deopt_id(),
2055 call->token_pos()),
2056 call->env(),
2057 FlowGraph::kEffect);
2058
2059 // Insert array length load and bounds check. 2050 // Insert array length load and bounds check.
2060 LoadFieldInstr* length = 2051 LoadFieldInstr* length =
2061 new(Z) LoadFieldInstr( 2052 new(Z) LoadFieldInstr(
2062 new(Z) Value(*array), 2053 new(Z) Value(*array),
2063 CheckArrayBoundInstr::LengthOffsetFor(array_cid), 2054 CheckArrayBoundInstr::LengthOffsetFor(array_cid),
2064 Type::ZoneHandle(Z, Type::SmiType()), 2055 Type::ZoneHandle(Z, Type::SmiType()),
2065 call->token_pos()); 2056 call->token_pos());
2066 length->set_is_immutable( 2057 length->set_is_immutable(
2067 CheckArrayBoundInstr::IsFixedLengthArrayType(array_cid)); 2058 CheckArrayBoundInstr::IsFixedLengthArrayType(array_cid));
2068 length->set_result_cid(kSmiCid); 2059 length->set_result_cid(kSmiCid);
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
2513 2504
2514 2505
2515 static intptr_t PrepareInlineByteArrayBaseOp( 2506 static intptr_t PrepareInlineByteArrayBaseOp(
2516 FlowGraph* flow_graph, 2507 FlowGraph* flow_graph,
2517 Instruction* call, 2508 Instruction* call,
2518 intptr_t array_cid, 2509 intptr_t array_cid,
2519 intptr_t view_cid, 2510 intptr_t view_cid,
2520 Definition** array, 2511 Definition** array,
2521 Definition* byte_index, 2512 Definition* byte_index,
2522 Instruction** cursor) { 2513 Instruction** cursor) {
2523 // Insert byte_index smi check.
2524 *cursor = flow_graph->AppendTo(*cursor,
2525 new(Z) CheckSmiInstr(
2526 new(Z) Value(byte_index),
2527 call->deopt_id(),
2528 call->token_pos()),
2529 call->env(),
2530 FlowGraph::kEffect);
2531
2532 LoadFieldInstr* length = 2514 LoadFieldInstr* length =
2533 new(Z) LoadFieldInstr( 2515 new(Z) LoadFieldInstr(
2534 new(Z) Value(*array), 2516 new(Z) Value(*array),
2535 CheckArrayBoundInstr::LengthOffsetFor(array_cid), 2517 CheckArrayBoundInstr::LengthOffsetFor(array_cid),
2536 Type::ZoneHandle(Z, Type::SmiType()), 2518 Type::ZoneHandle(Z, Type::SmiType()),
2537 call->token_pos()); 2519 call->token_pos());
2538 length->set_is_immutable(true); 2520 length->set_is_immutable(true);
2539 length->set_result_cid(kSmiCid); 2521 length->set_result_cid(kSmiCid);
2540 length->set_recognized_kind( 2522 length->set_recognized_kind(
2541 LoadFieldInstr::RecognizedKindFromArrayCid(array_cid)); 2523 LoadFieldInstr::RecognizedKindFromArrayCid(array_cid));
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2822 2804
2823 2805
2824 // Returns the LoadIndexedInstr. 2806 // Returns the LoadIndexedInstr.
2825 static Definition* PrepareInlineStringIndexOp( 2807 static Definition* PrepareInlineStringIndexOp(
2826 FlowGraph* flow_graph, 2808 FlowGraph* flow_graph,
2827 Instruction* call, 2809 Instruction* call,
2828 intptr_t cid, 2810 intptr_t cid,
2829 Definition* str, 2811 Definition* str,
2830 Definition* index, 2812 Definition* index,
2831 Instruction* cursor) { 2813 Instruction* cursor) {
2832
2833 cursor = flow_graph->AppendTo(cursor,
2834 new(Z) CheckSmiInstr(
2835 new(Z) Value(index),
2836 call->deopt_id(),
2837 call->token_pos()),
2838 call->env(),
2839 FlowGraph::kEffect);
2840
2841 // Load the length of the string. 2814 // Load the length of the string.
2842 // Treat length loads as mutable (i.e. affected by side effects) to avoid 2815 // Treat length loads as mutable (i.e. affected by side effects) to avoid
2843 // hoisting them since we can't hoist the preceding class-check. This 2816 // hoisting them since we can't hoist the preceding class-check. This
2844 // is because of externalization of strings that affects their class-id. 2817 // is because of externalization of strings that affects their class-id.
2845 LoadFieldInstr* length = new(Z) LoadFieldInstr( 2818 LoadFieldInstr* length = new(Z) LoadFieldInstr(
2846 new(Z) Value(str), 2819 new(Z) Value(str),
2847 String::length_offset(), 2820 String::length_offset(),
2848 Type::ZoneHandle(Z, Type::SmiType()), 2821 Type::ZoneHandle(Z, Type::SmiType()),
2849 str->token_pos()); 2822 str->token_pos());
2850 length->set_result_cid(kSmiCid); 2823 length->set_result_cid(kSmiCid);
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
3254 call, entry, last); 3227 call, entry, last);
3255 case MethodRecognizer::kSmi_bitAndFromSmi: 3228 case MethodRecognizer::kSmi_bitAndFromSmi:
3256 return InlineSmiBitAndFromSmi(flow_graph, call, entry, last); 3229 return InlineSmiBitAndFromSmi(flow_graph, call, entry, last);
3257 default: 3230 default:
3258 return false; 3231 return false;
3259 } 3232 }
3260 } 3233 }
3261 3234
3262 3235
3263 } // namespace dart 3236 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/flow_graph_type_propagator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698