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

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

Issue 513213002: Generate some intrinsics using our IR. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed latest comments Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
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 // Class for intrinsifying functions. 4 // Class for intrinsifying functions.
5 5
6 #include "vm/assembler.h" 6 #include "vm/assembler.h"
7 #include "vm/intrinsifier.h" 7 #include "vm/intrinsifier.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
11 11
12 #include "vm/flow_graph.h"
13 #include "vm/flow_graph_compiler.h"
14 #include "vm/flow_graph_allocator.h"
15 #include "vm/flow_graph_builder.h"
16 #include "vm/il_printer.h"
17 #include "vm/intermediate_language.h"
18 #include "vm/parser.h"
19
12 namespace dart { 20 namespace dart {
13 21
14 DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible"); 22 DEFINE_FLAG(bool, intrinsify, true, "Instrinsify when possible");
15 DECLARE_FLAG(bool, throw_on_javascript_int_overflow); 23 DECLARE_FLAG(bool, throw_on_javascript_int_overflow);
24 DECLARE_FLAG(bool, code_comments);
25 DECLARE_FLAG(bool, print_flow_graph);
26 DECLARE_FLAG(bool, print_flow_graph_optimized);
16 27
17 bool Intrinsifier::CanIntrinsify(const Function& function) { 28 bool Intrinsifier::CanIntrinsify(const Function& function) {
18 if (!FLAG_intrinsify) return false; 29 if (!FLAG_intrinsify) return false;
19 if (function.IsClosureFunction()) return false; 30 if (function.IsClosureFunction()) return false;
20 // Can occur because of compile-all flag. 31 // Can occur because of compile-all flag.
21 if (function.is_external()) return false; 32 if (function.is_external()) return false;
22 return function.is_intrinsic(); 33 return function.is_intrinsic();
23 } 34 }
24 35
25 36
(...skipping 26 matching lines...) Expand all
52 func = cls.LookupFunctionAllowPrivate(str); \ 63 func = cls.LookupFunctionAllowPrivate(str); \
53 } \ 64 } \
54 ASSERT(!func.IsNull()); \ 65 ASSERT(!func.IsNull()); \
55 func.set_is_intrinsic(true); 66 func.set_is_intrinsic(true);
56 67
57 // Set up all core lib functions that can be intrisified. 68 // Set up all core lib functions that can be intrisified.
58 lib = Library::CoreLibrary(); 69 lib = Library::CoreLibrary();
59 ASSERT(!lib.IsNull()); 70 ASSERT(!lib.IsNull());
60 CORE_LIB_INTRINSIC_LIST(SETUP_FUNCTION); 71 CORE_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
61 CORE_INTEGER_LIB_INTRINSIC_LIST(SETUP_FUNCTION); 72 CORE_INTEGER_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
73 GRAPH_CORE_INTRINSICS_LIST(SETUP_FUNCTION);
62 74
63 // Set up all math lib functions that can be intrisified. 75 // Set up all math lib functions that can be intrisified.
64 lib = Library::MathLibrary(); 76 lib = Library::MathLibrary();
65 ASSERT(!lib.IsNull()); 77 ASSERT(!lib.IsNull());
66 MATH_LIB_INTRINSIC_LIST(SETUP_FUNCTION); 78 MATH_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
67 79
68 // Set up all dart:typed_data lib functions that can be intrisified. 80 // Set up all dart:typed_data lib functions that can be intrisified.
69 lib = Library::TypedDataLibrary(); 81 lib = Library::TypedDataLibrary();
70 ASSERT(!lib.IsNull()); 82 ASSERT(!lib.IsNull());
71 TYPED_DATA_LIB_INTRINSIC_LIST(SETUP_FUNCTION); 83 TYPED_DATA_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
84 GRAPH_TYPED_DATA_INTRINSICS_LIST(SETUP_FUNCTION);
72 85
73 // Setup all dart:profiler lib functions that can be intrinsified. 86 // Setup all dart:profiler lib functions that can be intrinsified.
74 lib = Library::ProfilerLibrary(); 87 lib = Library::ProfilerLibrary();
75 ASSERT(!lib.IsNull()); 88 ASSERT(!lib.IsNull());
76 PROFILER_LIB_INTRINSIC_LIST(SETUP_FUNCTION); 89 PROFILER_LIB_INTRINSIC_LIST(SETUP_FUNCTION);
77 90
78 #undef SETUP_FUNCTION 91 #undef SETUP_FUNCTION
79 } 92 }
80 93
81 94
82 void Intrinsifier::Intrinsify(const Function& function, Assembler* assembler) { 95 static void EmitCodeFor(FlowGraphCompiler* compiler,
83 if (!CanIntrinsify(function)) return; 96 FlowGraph* graph) {
97 // The FlowGraph here is constructed by the intrinsics builder methods, and
98 // is different from compiler->flow_graph(), the original method's flow graph.
99 compiler->assembler()->Comment("Graph intrinsic");
100 for (intptr_t i = 0; i < graph->reverse_postorder().length(); i++) {
101 BlockEntryInstr* block = graph->reverse_postorder()[i];
102 if (block->IsGraphEntry()) continue; // No code for graph entry needed.
103 for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
104 Instruction* instr = it.Current();
105 if (FLAG_code_comments) compiler->EmitComment(instr);
106 if (instr->IsParallelMove()) {
107 compiler->parallel_move_resolver()->EmitNativeCode(
108 instr->AsParallelMove());
109 } else {
110 ASSERT(instr->locs() != NULL);
111 // Calls are not supported in intrinsics code.
112 ASSERT(!instr->locs()->always_calls());
113 instr->EmitNativeCode(compiler);
114 }
115 }
116 }
117 }
118
119
120 bool Intrinsifier::GraphIntrinsify(ParsedFunction* parsed_function,
121 FlowGraphCompiler* compiler) {
122 ZoneGrowableArray<const ICData*>* ic_data_array =
123 new ZoneGrowableArray<const ICData*>();
124 FlowGraphBuilder builder(parsed_function,
125 *ic_data_array,
126 NULL, // NULL = not inlining.
127 Isolate::kNoDeoptId); // No OSR id.
128
129 intptr_t block_id = builder.AllocateBlockId();
130 TargetEntryInstr* normal_entry =
131 new TargetEntryInstr(block_id,
132 CatchClauseNode::kInvalidTryIndex);
133 GraphEntryInstr* graph_entry = new GraphEntryInstr(
134 parsed_function, normal_entry, Isolate::kNoDeoptId); // No OSR id.
135 FlowGraph* graph = new FlowGraph(builder, graph_entry, block_id);
136 const Function& function = parsed_function->function();
137 switch (function.recognized_kind()) {
138 #define EMIT_CASE(test_class_name, test_function_name, enum_name, fp) \
139 case MethodRecognizer::k##enum_name: \
140 ASSERT(function.CheckSourceFingerprint(fp)); \
141 if (!Build_##enum_name(graph)) return false; \
142 break;
143
144 GRAPH_INTRINSICS_LIST(EMIT_CASE);
145 default:
146 return false;
147 #undef EMIT_CASE
148 }
149
150 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) {
151 OS::Print("Intrinsic graph before\n");
152 FlowGraphPrinter printer(*graph);
153 printer.PrintBlocks();
154 }
155
156 // Perform register allocation on the SSA graph.
157 FlowGraphAllocator allocator(*graph, true); // Intrinsic mode.
158 allocator.AllocateRegisters();
159
160 if (FLAG_print_flow_graph || FLAG_print_flow_graph_optimized) {
161 OS::Print("Intrinsic graph after\n");
162 FlowGraphPrinter printer(*graph);
163 printer.PrintBlocks();
164 }
165 EmitCodeFor(compiler, graph);
166 return true;
167 }
168
169
170 void Intrinsifier::Intrinsify(ParsedFunction* parsed_function,
171 FlowGraphCompiler* compiler) {
172 const Function& function = parsed_function->function();
173 if (!CanIntrinsify(function)) {
174 return;
175 }
176
177 if (GraphIntrinsify(parsed_function, compiler)) {
178 return;
179 }
84 180
85 #define EMIT_CASE(test_class_name, test_function_name, enum_name, fp) \ 181 #define EMIT_CASE(test_class_name, test_function_name, enum_name, fp) \
86 case MethodRecognizer::k##enum_name: \ 182 case MethodRecognizer::k##enum_name: \
87 ASSERT(function.CheckSourceFingerprint(fp)); \ 183 ASSERT(function.CheckSourceFingerprint(fp)); \
88 assembler->Comment("Intrinsic"); \ 184 compiler->assembler()->Comment("Intrinsic"); \
89 enum_name(assembler); \ 185 enum_name(compiler->assembler()); \
90 break; 186 break;
91 187
92 if (FLAG_throw_on_javascript_int_overflow && (Smi::kBits >= 32)) { 188 if (FLAG_throw_on_javascript_int_overflow && (Smi::kBits >= 32)) {
93 // Integer intrinsics are in the core library, but we don't want to 189 // Integer intrinsics are in the core library, but we don't want to
94 // intrinsify when Smi > 32 bits if we are looking for javascript integer 190 // intrinsify when Smi > 32 bits if we are looking for javascript integer
95 // overflow. 191 // overflow.
96 switch (function.recognized_kind()) { 192 switch (function.recognized_kind()) {
97 CORE_LIB_INTRINSIC_LIST(EMIT_CASE); 193 ALL_INTRINSICS_NO_INTEGER_LIB_LIST(EMIT_CASE);
98 MATH_LIB_INTRINSIC_LIST(EMIT_CASE);
99 TYPED_DATA_LIB_INTRINSIC_LIST(EMIT_CASE);
100 PROFILER_LIB_INTRINSIC_LIST(EMIT_CASE);
101 default: 194 default:
102 break; 195 break;
103 } 196 }
104 } else { 197 } else {
105 switch (function.recognized_kind()) { 198 switch (function.recognized_kind()) {
106 CORE_LIB_INTRINSIC_LIST(EMIT_CASE); 199 ALL_INTRINSICS_LIST(EMIT_CASE);
107 CORE_INTEGER_LIB_INTRINSIC_LIST(EMIT_CASE);
108 MATH_LIB_INTRINSIC_LIST(EMIT_CASE);
109 TYPED_DATA_LIB_INTRINSIC_LIST(EMIT_CASE);
110 PROFILER_LIB_INTRINSIC_LIST(EMIT_CASE);
111 default: 200 default:
112 UNREACHABLE(); 201 UNREACHABLE();
113 break; 202 break;
114 } 203 }
115 } 204 }
116 #undef EMIT_INTRINSIC 205 #undef EMIT_INTRINSIC
117 } 206 }
118 207
208
209 class BlockBuilder : public ValueObject {
210 public:
211 BlockBuilder(FlowGraph* flow_graph, TargetEntryInstr* entry)
212 : flow_graph_(flow_graph), entry_(entry), current_(entry) { }
213
214 Definition* AddToInitialDefinitions(Definition* def) {
215 def->set_ssa_temp_index(flow_graph_->alloc_ssa_temp_index());
216 flow_graph_->AddToInitialDefinitions(def);
217 return def;
218 }
219
220 Definition* AddDefinition(Definition* def) {
221 def->set_ssa_temp_index(flow_graph_->alloc_ssa_temp_index());
222 current_ = current_->AppendInstruction(def);
223 return def;
224 }
225
226 Instruction* AddInstruction(Instruction* instr) {
227 current_ = current_->AppendInstruction(instr);
228 return instr;
229 }
230
231 void AddIntrinsicReturn(Value* value) {
232 ReturnInstr* instr = new ReturnInstr(TokenPos(), value);
233 AddInstruction(instr);
234 entry_->set_last_instruction(instr);
235 }
236
237 Definition* AddParameter(intptr_t index) {
238 intptr_t adjustment = Intrinsifier::ParameterSlotFromSp();
239 return AddToInitialDefinitions(
240 new ParameterInstr(adjustment + index,
241 flow_graph_->graph_entry(),
242 SPREG));
243 }
244
245 intptr_t TokenPos() {
246 return flow_graph_->parsed_function().function().token_pos();
247 }
248
249 private:
250 FlowGraph* flow_graph_;
251 BlockEntryInstr* entry_;
252 Instruction* current_;
253 };
254
255
256 static void PrepareIndexedOp(BlockBuilder* builder,
257 Definition* array,
258 Definition* index,
259 intptr_t length_offset) {
260 intptr_t token_pos = builder->TokenPos();
261 builder->AddInstruction(
262 new CheckSmiInstr(new Value(index),
263 Isolate::kNoDeoptId,
264 token_pos));
265
266 Definition* length = builder->AddDefinition(
267 new LoadFieldInstr(new Value(array),
268 length_offset,
269 Type::ZoneHandle(Type::SmiType()),
270 true)); // immutable
271 builder->AddInstruction(
272 new CheckArrayBoundInstr(new Value(length),
273 new Value(index),
274 Isolate::kNoDeoptId));
275 }
276
277
278 bool Intrinsifier::Build_ObjectArrayGetIndexed(FlowGraph* flow_graph) {
279 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
280 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
281 BlockBuilder builder(flow_graph, normal_entry);
282
283 Definition* index = builder.AddParameter(1);
284 Definition* array = builder.AddParameter(2);
285
286 PrepareIndexedOp(&builder, array, index, Array::length_offset());
287
288 Definition* result = builder.AddDefinition(
289 new LoadIndexedInstr(new Value(array),
290 new Value(index),
291 Instance::ElementSizeFor(kArrayCid), // index scale
292 kArrayCid,
293 Isolate::kNoDeoptId,
294 builder.TokenPos()));
295 builder.AddIntrinsicReturn(new Value(result));
296 return true;
297 }
298
299
300 bool Intrinsifier::Build_ImmutableArrayGetIndexed(FlowGraph* flow_graph) {
301 return Build_ObjectArrayGetIndexed(flow_graph);
302 }
303
304
305 bool Intrinsifier::Build_Uint8ArrayGetIndexed(FlowGraph* flow_graph) {
306 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
307 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
308 BlockBuilder builder(flow_graph, normal_entry);
309
310 Definition* index = builder.AddParameter(1);
311 Definition* array = builder.AddParameter(2);
312
313 PrepareIndexedOp(&builder, array, index, TypedData::length_offset());
314
315 Definition* result = builder.AddDefinition(
316 new LoadIndexedInstr(new Value(array),
317 new Value(index),
318 1, // index scale
319 kTypedDataUint8ArrayCid,
320 Isolate::kNoDeoptId,
321 builder.TokenPos()));
322 builder.AddIntrinsicReturn(new Value(result));
323 return true;
324 }
325
326
327 bool Intrinsifier::Build_ExternalUint8ArrayGetIndexed(FlowGraph* flow_graph) {
328 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
329 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
330 BlockBuilder builder(flow_graph, normal_entry);
331
332 Definition* index = builder.AddParameter(1);
333 Definition* array = builder.AddParameter(2);
334
335 PrepareIndexedOp(&builder, array, index, ExternalTypedData::length_offset());
336
337 Definition* elements = builder.AddDefinition(
338 new LoadUntaggedInstr(new Value(array),
339 ExternalTypedData::data_offset()));
340 Definition* result = builder.AddDefinition(
341 new LoadIndexedInstr(new Value(elements),
342 new Value(index),
343 1, // index scale
344 kExternalTypedDataUint8ArrayCid,
345 Isolate::kNoDeoptId,
346 builder.TokenPos()));
347 builder.AddIntrinsicReturn(new Value(result));
348 return true;
349 }
350
351
352 bool Intrinsifier::Build_Uint8ArraySetIndexed(FlowGraph* flow_graph) {
353 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
354 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
355 BlockBuilder builder(flow_graph, normal_entry);
356
357 Definition* value = builder.AddParameter(1);
358 Definition* index = builder.AddParameter(2);
359 Definition* array = builder.AddParameter(3);
360
361 PrepareIndexedOp(&builder, array, index, TypedData::length_offset());
362
363 builder.AddInstruction(
364 new CheckSmiInstr(new Value(value),
365 Isolate::kNoDeoptId,
366 builder.TokenPos()));
367
368 builder.AddInstruction(
369 new StoreIndexedInstr(new Value(array),
370 new Value(index),
371 new Value(value),
372 kNoStoreBarrier,
373 1, // index scale
374 kTypedDataUint8ArrayCid,
375 Isolate::kNoDeoptId,
376 builder.TokenPos()));
377 // Return null.
378 Definition* null_def = builder.AddDefinition(
379 new ConstantInstr(Object::ZoneHandle(Object::null())));
380 builder.AddIntrinsicReturn(new Value(null_def));
381 return true;
382 }
383
384
385 bool Intrinsifier::Build_ExternalUint8ArraySetIndexed(FlowGraph* flow_graph) {
386 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
387 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
388 BlockBuilder builder(flow_graph, normal_entry);
389
390 Definition* value = builder.AddParameter(1);
391 Definition* index = builder.AddParameter(2);
392 Definition* array = builder.AddParameter(3);
393
394 PrepareIndexedOp(&builder, array, index, ExternalTypedData::length_offset());
395
396 builder.AddInstruction(
397 new CheckSmiInstr(new Value(value),
398 Isolate::kNoDeoptId,
399 builder.TokenPos()));
400 Definition* elements = builder.AddDefinition(
401 new LoadUntaggedInstr(new Value(array),
402 ExternalTypedData::data_offset()));
403 builder.AddInstruction(
404 new StoreIndexedInstr(new Value(elements),
405 new Value(index),
406 new Value(value),
407 kNoStoreBarrier,
408 1, // index scale
409 kExternalTypedDataUint8ArrayCid,
410 Isolate::kNoDeoptId,
411 builder.TokenPos()));
412 // Return null.
413 Definition* null_def = builder.AddDefinition(
414 new ConstantInstr(Object::ZoneHandle(Object::null())));
415 builder.AddIntrinsicReturn(new Value(null_def));
416 return true;
417 }
418
419
420 bool Intrinsifier::Build_Float64ArraySetIndexed(FlowGraph* flow_graph) {
421 if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false;
422
423 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
424 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
425 BlockBuilder builder(flow_graph, normal_entry);
426
427 Definition* value = builder.AddParameter(1);
428 Definition* index = builder.AddParameter(2);
429 Definition* array = builder.AddParameter(3);
430
431 PrepareIndexedOp(&builder, array, index, TypedData::length_offset());
432
433 const ICData& value_check = ICData::ZoneHandle(ICData::New(
434 flow_graph->parsed_function().function(),
435 String::Handle(flow_graph->parsed_function().function().name()),
436 Object::empty_array(), // Dummy args. descr.
437 Isolate::kNoDeoptId,
438 1));
439 value_check.AddReceiverCheck(kDoubleCid,
440 flow_graph->parsed_function().function());
441 builder.AddInstruction(
442 new CheckClassInstr(new Value(value),
443 Isolate::kNoDeoptId,
444 value_check,
445 builder.TokenPos()));
446 Definition* double_value = builder.AddDefinition(
447 new UnboxDoubleInstr(new Value(value), Isolate::kNoDeoptId));
448 // Manually adjust reaching type because there is no type propagation
449 // when building intrinsics.
450 double_value->AsUnboxDouble()->value()->SetReachingType(
451 ZoneCompileType::Wrap(CompileType::FromCid(kDoubleCid)));
452
453 builder.AddInstruction(
454 new StoreIndexedInstr(new Value(array),
455 new Value(index),
456 new Value(double_value),
457 kNoStoreBarrier,
458 8, // index scale
459 kTypedDataFloat64ArrayCid,
460 Isolate::kNoDeoptId,
461 builder.TokenPos()));
462 // Return null.
463 Definition* null_def = builder.AddDefinition(
464 new ConstantInstr(Object::ZoneHandle(Object::null())));
465 builder.AddIntrinsicReturn(new Value(null_def));
466 return true;
467 }
468
469
470 bool Intrinsifier::Build_Float64ArrayGetIndexed(FlowGraph* flow_graph) {
471 if (!FlowGraphCompiler::SupportsUnboxedDoubles()) return false;
472
473 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
474 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
475 BlockBuilder builder(flow_graph, normal_entry);
476
477 Definition* index = builder.AddParameter(1);
478 Definition* array = builder.AddParameter(2);
479
480 PrepareIndexedOp(&builder, array, index, TypedData::length_offset());
481
482 Definition* unboxed_value = builder.AddDefinition(
483 new LoadIndexedInstr(new Value(array),
484 new Value(index),
485 8, // index scale
486 kTypedDataFloat64ArrayCid,
487 Isolate::kNoDeoptId,
488 builder.TokenPos()));
489 Definition* result = builder.AddDefinition(
490 new BoxDoubleInstr(new Value(unboxed_value)));
491 builder.AddIntrinsicReturn(new Value(result));
492 return true;
493 }
494
495
496 static bool BuildLoadField(FlowGraph* flow_graph, intptr_t offset) {
497 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
498 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
499 BlockBuilder builder(flow_graph, normal_entry);
500
501 Definition* array = builder.AddParameter(1);
502
503 Definition* length = builder.AddDefinition(
504 new LoadFieldInstr(new Value(array),
505 offset,
506 Type::ZoneHandle(),
507 builder.TokenPos()));
508 builder.AddIntrinsicReturn(new Value(length));
509 return true;
510 }
511
512
513 bool Intrinsifier::Build_ObjectArrayLength(FlowGraph* flow_graph) {
514 return BuildLoadField(flow_graph, Array::length_offset());
515 }
516
517
518 bool Intrinsifier::Build_ImmutableArrayLength(FlowGraph* flow_graph) {
519 return BuildLoadField(flow_graph, Array::length_offset());
520 }
521
522
523 bool Intrinsifier::Build_GrowableArrayLength(FlowGraph* flow_graph) {
524 return BuildLoadField(flow_graph, GrowableObjectArray::length_offset());
525 }
526
527
528 bool Intrinsifier::Build_StringBaseLength(FlowGraph* flow_graph) {
529 return BuildLoadField(flow_graph, String::length_offset());
530 }
531
532
533 bool Intrinsifier::Build_TypedDataLength(FlowGraph* flow_graph) {
534 return BuildLoadField(flow_graph, TypedData::length_offset());
535 }
536
537
538 bool Intrinsifier::Build_GrowableArrayCapacity(FlowGraph* flow_graph) {
539 GraphEntryInstr* graph_entry = flow_graph->graph_entry();
540 TargetEntryInstr* normal_entry = graph_entry->normal_entry();
541 BlockBuilder builder(flow_graph, normal_entry);
542
543 Definition* array = builder.AddParameter(1);
544
545 Definition* backing_store = builder.AddDefinition(
546 new LoadFieldInstr(new Value(array),
547 GrowableObjectArray::data_offset(),
548 Type::ZoneHandle(),
549 builder.TokenPos()));
550 Definition* capacity = builder.AddDefinition(
551 new LoadFieldInstr(new Value(backing_store),
552 Array::length_offset(),
553 Type::ZoneHandle(),
554 builder.TokenPos()));
555 builder.AddIntrinsicReturn(new Value(capacity));
556 return true;
557 }
558
559
119 } // namespace dart 560 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698