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

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

Issue 2768153002: When generating CodeSourceMaps, reassign function ids once per function instead of once per inlinin… (Closed)
Patch Set: Created 3 years, 9 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/code_descriptors.h ('k') | runtime/vm/raw_object.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) 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 4
5 #include "vm/code_descriptors.h" 5 #include "vm/code_descriptors.h"
6 6
7 #include "vm/log.h" 7 #include "vm/log.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 const GrowableArray<const Function*>& inline_id_to_function) 233 const GrowableArray<const Function*>& inline_id_to_function)
234 : buffered_pc_offset_(0), 234 : buffered_pc_offset_(0),
235 buffered_inline_id_stack_(), 235 buffered_inline_id_stack_(),
236 buffered_token_pos_stack_(), 236 buffered_token_pos_stack_(),
237 written_pc_offset_(0), 237 written_pc_offset_(0),
238 written_inline_id_stack_(), 238 written_inline_id_stack_(),
239 written_token_pos_stack_(), 239 written_token_pos_stack_(),
240 caller_inline_id_(caller_inline_id), 240 caller_inline_id_(caller_inline_id),
241 inline_id_to_token_pos_(inline_id_to_token_pos), 241 inline_id_to_token_pos_(inline_id_to_token_pos),
242 inline_id_to_function_(inline_id_to_function), 242 inline_id_to_function_(inline_id_to_function),
243 inlined_functions_(
244 GrowableObjectArray::Handle(GrowableObjectArray::New(Heap::kOld))),
243 buffer_(NULL), 245 buffer_(NULL),
244 stream_(&buffer_, zone_allocator, 64), 246 stream_(&buffer_, zone_allocator, 64),
245 stack_traces_only_(stack_traces_only) { 247 stack_traces_only_(stack_traces_only) {
246 buffered_inline_id_stack_.Add(0); 248 buffered_inline_id_stack_.Add(0);
247 buffered_token_pos_stack_.Add(kInitialPosition); 249 buffered_token_pos_stack_.Add(kInitialPosition);
248 written_inline_id_stack_.Add(0); 250 written_inline_id_stack_.Add(0);
249 written_token_pos_stack_.Add(kInitialPosition); 251 written_token_pos_stack_.Add(kInitialPosition);
250 } 252 }
251 253
252 254
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 RawPcDescriptors::kIcCall | RawPcDescriptors::kUnoptStaticCall | 383 RawPcDescriptors::kIcCall | RawPcDescriptors::kUnoptStaticCall |
382 RawPcDescriptors::kRuntimeCall | RawPcDescriptors::kOther; 384 RawPcDescriptors::kRuntimeCall | RawPcDescriptors::kOther;
383 if (stack_traces_only_ && ((kind & kCanThrow) != 0)) { 385 if (stack_traces_only_ && ((kind & kCanThrow) != 0)) {
384 BufferChangePosition(pos); 386 BufferChangePosition(pos);
385 BufferAdvancePC(pc_offset - buffered_pc_offset_); 387 BufferAdvancePC(pc_offset - buffered_pc_offset_);
386 FlushBuffer(); 388 FlushBuffer();
387 } 389 }
388 } 390 }
389 391
390 392
393 intptr_t CodeSourceMapBuilder::GetFunctionId(intptr_t inline_id) {
394 const Function& function = *inline_id_to_function_[inline_id];
395 for (intptr_t i = 0; i < inlined_functions_.Length(); i++) {
396 if (inlined_functions_.At(i) == function.raw()) {
397 return i;
398 }
399 }
400 inlined_functions_.Add(function, Heap::kOld);
401 return inlined_functions_.Length() - 1;
402 }
403
404
391 RawArray* CodeSourceMapBuilder::InliningIdToFunction() { 405 RawArray* CodeSourceMapBuilder::InliningIdToFunction() {
392 if (inline_id_to_function_.length() <= 1) { 406 if (inlined_functions_.Length() == 0) {
393 // Not optimizing, or optimizing and nothing inlined.
394 return Object::empty_array().raw(); 407 return Object::empty_array().raw();
395 } 408 }
396 const Array& res = 409 return Array::MakeArray(inlined_functions_);
397 Array::Handle(Array::New(inline_id_to_function_.length(), Heap::kOld));
398 for (intptr_t i = 0; i < inline_id_to_function_.length(); i++) {
399 res.SetAt(i, *inline_id_to_function_[i]);
400 }
401 return res.raw();
402 } 410 }
403 411
404 412
405 RawCodeSourceMap* CodeSourceMapBuilder::Finalize() { 413 RawCodeSourceMap* CodeSourceMapBuilder::Finalize() {
406 if (!stack_traces_only_) { 414 if (!stack_traces_only_) {
407 FlushBuffer(); 415 FlushBuffer();
408 } 416 }
409 intptr_t length = stream_.bytes_written(); 417 intptr_t length = stream_.bytes_written();
410 const CodeSourceMap& map = CodeSourceMap::Handle(CodeSourceMap::New(length)); 418 const CodeSourceMap& map = CodeSourceMap::Handle(CodeSourceMap::New(length));
411 NoSafepointScope no_safepoint; 419 NoSafepointScope no_safepoint;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 break; 648 break;
641 } 649 }
642 default: 650 default:
643 UNREACHABLE(); 651 UNREACHABLE();
644 } 652 }
645 } 653 }
646 THR_Print("}\n"); 654 THR_Print("}\n");
647 } 655 }
648 656
649 } // namespace dart 657 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698