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

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

Issue 2622053002: Refactor snapshots pieces to include a section for loading instructions into the heap of a regular … (Closed)
Patch Set: . Created 3 years, 11 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/metrics_test.cc ('k') | runtime/vm/object_graph.cc » ('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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/become.h" 10 #include "vm/become.h"
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 cls = isolate->class_table()->At(kFreeListElement); 1044 cls = isolate->class_table()->At(kFreeListElement);
1045 cls.set_name(Symbols::FreeListElement()); 1045 cls.set_name(Symbols::FreeListElement());
1046 cls = isolate->class_table()->At(kForwardingCorpse); 1046 cls = isolate->class_table()->At(kForwardingCorpse);
1047 cls.set_name(Symbols::ForwardingCorpse()); 1047 cls.set_name(Symbols::ForwardingCorpse());
1048 1048
1049 { 1049 {
1050 ASSERT(isolate == Dart::vm_isolate()); 1050 ASSERT(isolate == Dart::vm_isolate());
1051 WritableVMIsolateScope scope(Thread::Current()); 1051 WritableVMIsolateScope scope(Thread::Current());
1052 PremarkingVisitor premarker; 1052 PremarkingVisitor premarker;
1053 ASSERT(isolate->heap()->UsedInWords(Heap::kNew) == 0); 1053 ASSERT(isolate->heap()->UsedInWords(Heap::kNew) == 0);
1054 isolate->heap()->IterateOldObjectsNoEmbedderPages(&premarker); 1054 isolate->heap()->IterateOldObjectsNoExternalPages(&premarker);
1055 // Make the VM isolate read-only again after setting all objects as marked. 1055 // Make the VM isolate read-only again after setting all objects as marked.
1056 } 1056 }
1057 } 1057 }
1058 1058
1059 1059
1060 void Object::set_vm_isolate_snapshot_object_table(const Array& table) { 1060 void Object::set_vm_isolate_snapshot_object_table(const Array& table) {
1061 ASSERT(Isolate::Current() == Dart::vm_isolate()); 1061 ASSERT(Isolate::Current() == Dart::vm_isolate());
1062 *vm_isolate_snapshot_object_table_ = table.raw(); 1062 *vm_isolate_snapshot_object_table_ = table.raw();
1063 } 1063 }
1064 1064
(...skipping 2429 matching lines...) Expand 10 before | Expand all | Expand 10 after
3494 if (largest_seen < function.end_token_pos()) { 3494 if (largest_seen < function.end_token_pos()) {
3495 largest_seen = function.end_token_pos(); 3495 largest_seen = function.end_token_pos();
3496 } 3496 }
3497 } 3497 }
3498 } 3498 }
3499 return TokenPosition(largest_seen); 3499 return TokenPosition(largest_seen);
3500 } 3500 }
3501 3501
3502 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); 3502 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens());
3503 if (tkns.IsNull()) { 3503 if (tkns.IsNull()) {
3504 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); 3504 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT);
3505 return TokenPosition::kNoSource; 3505 return TokenPosition::kNoSource;
3506 } 3506 }
3507 TokenStream::Iterator tkit(zone, tkns, token_pos(), 3507 TokenStream::Iterator tkit(zone, tkns, token_pos(),
3508 TokenStream::Iterator::kNoNewlines); 3508 TokenStream::Iterator::kNoNewlines);
3509 intptr_t level = 0; 3509 intptr_t level = 0;
3510 while (tkit.CurrentTokenKind() != Token::kEOS) { 3510 while (tkit.CurrentTokenKind() != Token::kEOS) {
3511 if (tkit.CurrentTokenKind() == Token::kLBRACE) { 3511 if (tkit.CurrentTokenKind() == Token::kLBRACE) {
3512 level++; 3512 level++;
3513 } else if (tkit.CurrentTokenKind() == Token::kRBRACE) { 3513 } else if (tkit.CurrentTokenKind() == Token::kRBRACE) {
3514 if (--level == 0) { 3514 if (--level == 0) {
(...skipping 4140 matching lines...) Expand 10 before | Expand all | Expand 10 after
7655 } 7655 }
7656 7656
7657 7657
7658 RawString* Field::InitializingExpression() const { 7658 RawString* Field::InitializingExpression() const {
7659 Thread* thread = Thread::Current(); 7659 Thread* thread = Thread::Current();
7660 Zone* zone = thread->zone(); 7660 Zone* zone = thread->zone();
7661 const class Script& scr = Script::Handle(zone, Script()); 7661 const class Script& scr = Script::Handle(zone, Script());
7662 ASSERT(!scr.IsNull()); 7662 ASSERT(!scr.IsNull());
7663 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); 7663 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens());
7664 if (tkns.IsNull()) { 7664 if (tkns.IsNull()) {
7665 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); 7665 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT);
7666 return String::null(); 7666 return String::null();
7667 } 7667 }
7668 TokenStream::Iterator tkit(zone, tkns, token_pos()); 7668 TokenStream::Iterator tkit(zone, tkns, token_pos());
7669 ASSERT(Token::IsIdentifier(tkit.CurrentTokenKind())); 7669 ASSERT(Token::IsIdentifier(tkit.CurrentTokenKind()));
7670 #if defined(DEBUG) 7670 #if defined(DEBUG)
7671 const String& literal = String::Handle(zone, tkit.CurrentLiteral()); 7671 const String& literal = String::Handle(zone, tkit.CurrentLiteral());
7672 ASSERT(literal.raw() == name()); 7672 ASSERT(literal.raw() == name());
7673 #endif 7673 #endif
7674 tkit.Advance(); 7674 tkit.Advance();
7675 if (tkit.CurrentTokenKind() != Token::kASSIGN) { 7675 if (tkit.CurrentTokenKind() != Token::kASSIGN) {
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
8808 8808
8809 8809
8810 RawString* Script::GenerateSource() const { 8810 RawString* Script::GenerateSource() const {
8811 if (kind() == RawScript::kKernelTag) { 8811 if (kind() == RawScript::kKernelTag) {
8812 // In kernel it's embedded. 8812 // In kernel it's embedded.
8813 return raw_ptr()->source_; 8813 return raw_ptr()->source_;
8814 } 8814 }
8815 8815
8816 const TokenStream& token_stream = TokenStream::Handle(tokens()); 8816 const TokenStream& token_stream = TokenStream::Handle(tokens());
8817 if (token_stream.IsNull()) { 8817 if (token_stream.IsNull()) {
8818 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); 8818 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT);
8819 return String::null(); 8819 return String::null();
8820 } 8820 }
8821 return token_stream.GenerateSource(); 8821 return token_stream.GenerateSource();
8822 } 8822 }
8823 8823
8824 8824
8825 void Script::set_compile_time_constants(const Array& value) const { 8825 void Script::set_compile_time_constants(const Array& value) const {
8826 StorePointer(&raw_ptr()->compile_time_constants_, value.raw()); 8826 StorePointer(&raw_ptr()->compile_time_constants_, value.raw());
8827 } 8827 }
8828 8828
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
9065 *column = offset - smi.Value() + 1; 9065 *column = offset - smi.Value() + 1;
9066 } 9066 }
9067 if (token_len != NULL) { 9067 if (token_len != NULL) {
9068 *token_len = 1; 9068 *token_len = 1;
9069 } 9069 }
9070 return; 9070 return;
9071 } 9071 }
9072 9072
9073 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); 9073 const TokenStream& tkns = TokenStream::Handle(zone, tokens());
9074 if (tkns.IsNull()) { 9074 if (tkns.IsNull()) {
9075 ASSERT((Dart::snapshot_kind() == Snapshot::kAppAOT)); 9075 ASSERT((Dart::vm_snapshot_kind() == Snapshot::kAppAOT));
9076 *line = -1; 9076 *line = -1;
9077 if (column != NULL) { 9077 if (column != NULL) {
9078 *column = -1; 9078 *column = -1;
9079 } 9079 }
9080 if (token_len != NULL) { 9080 if (token_len != NULL) {
9081 *token_len = 1; 9081 *token_len = 1;
9082 } 9082 }
9083 return; 9083 return;
9084 } 9084 }
9085 if (column == NULL) { 9085 if (column == NULL) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
9223 } 9223 }
9224 result = result & ((static_cast<uint32_t>(1) << 31) - 1); 9224 result = result & ((static_cast<uint32_t>(1) << 31) - 1);
9225 ASSERT(result <= static_cast<uint32_t>(kMaxInt32)); 9225 ASSERT(result <= static_cast<uint32_t>(kMaxInt32));
9226 return result; 9226 return result;
9227 } 9227 }
9228 9228
9229 9229
9230 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { 9230 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const {
9231 const String& src = String::Handle(Source()); 9231 const String& src = String::Handle(Source());
9232 if (src.IsNull()) { 9232 if (src.IsNull()) {
9233 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); 9233 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT);
9234 return Symbols::OptimizedOut().raw(); 9234 return Symbols::OptimizedOut().raw();
9235 } 9235 }
9236 intptr_t relative_line_number = line_number - line_offset(); 9236 intptr_t relative_line_number = line_number - line_offset();
9237 intptr_t current_line = 1; 9237 intptr_t current_line = 1;
9238 intptr_t line_start_idx = -1; 9238 intptr_t line_start_idx = -1;
9239 intptr_t last_char_idx = -1; 9239 intptr_t last_char_idx = -1;
9240 for (intptr_t ix = 0; 9240 for (intptr_t ix = 0;
9241 (ix < src.Length()) && (current_line <= relative_line_number); ix++) { 9241 (ix < src.Length()) && (current_line <= relative_line_number); ix++) {
9242 if ((current_line == relative_line_number) && (line_start_idx < 0)) { 9242 if ((current_line == relative_line_number) && (line_start_idx < 0)) {
9243 line_start_idx = ix; 9243 line_start_idx = ix;
(...skipping 29 matching lines...) Expand all
9273 return GetSnippet(from_line, from_column, to_line, to_column); 9273 return GetSnippet(from_line, from_column, to_line, to_column);
9274 } 9274 }
9275 9275
9276 9276
9277 RawString* Script::GetSnippet(intptr_t from_line, 9277 RawString* Script::GetSnippet(intptr_t from_line,
9278 intptr_t from_column, 9278 intptr_t from_column,
9279 intptr_t to_line, 9279 intptr_t to_line,
9280 intptr_t to_column) const { 9280 intptr_t to_column) const {
9281 const String& src = String::Handle(Source()); 9281 const String& src = String::Handle(Source());
9282 if (src.IsNull()) { 9282 if (src.IsNull()) {
9283 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); 9283 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT);
9284 return Symbols::OptimizedOut().raw(); 9284 return Symbols::OptimizedOut().raw();
9285 } 9285 }
9286 intptr_t length = src.Length(); 9286 intptr_t length = src.Length();
9287 intptr_t line = 1 + line_offset(); 9287 intptr_t line = 1 + line_offset();
9288 intptr_t column = 1; 9288 intptr_t column = 1;
9289 intptr_t scan_position = 0; 9289 intptr_t scan_position = 0;
9290 intptr_t snippet_start = -1; 9290 intptr_t snippet_start = -1;
9291 intptr_t snippet_end = -1; 9291 intptr_t snippet_end = -1;
9292 if (from_line - line_offset() == 1) { 9292 if (from_line - line_offset() == 1) {
9293 column += col_offset(); 9293 column += col_offset();
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after
11204 11204
11205 11205
11206 bool LibraryPrefix::LoadLibrary() const { 11206 bool LibraryPrefix::LoadLibrary() const {
11207 // Non-deferred prefixes are loaded. 11207 // Non-deferred prefixes are loaded.
11208 ASSERT(is_deferred_load() || is_loaded()); 11208 ASSERT(is_deferred_load() || is_loaded());
11209 if (is_loaded()) { 11209 if (is_loaded()) {
11210 return true; // Load request has already completed. 11210 return true; // Load request has already completed.
11211 } 11211 }
11212 ASSERT(is_deferred_load()); 11212 ASSERT(is_deferred_load());
11213 ASSERT(num_imports() == 1); 11213 ASSERT(num_imports() == 1);
11214 if (Dart::snapshot_kind() == Snapshot::kAppAOT) { 11214 if (Dart::vm_snapshot_kind() == Snapshot::kAppAOT) {
11215 // The library list was tree-shaken away. 11215 // The library list was tree-shaken away.
11216 this->set_is_loaded(); 11216 this->set_is_loaded();
11217 return true; 11217 return true;
11218 } 11218 }
11219 // This is a prefix for a deferred library. If the library is not loaded 11219 // This is a prefix for a deferred library. If the library is not loaded
11220 // yet and isn't being loaded, call the library tag handler to schedule 11220 // yet and isn't being loaded, call the library tag handler to schedule
11221 // loading. Once all outstanding load requests have completed, the embedder 11221 // loading. Once all outstanding load requests have completed, the embedder
11222 // will call the core library to: 11222 // will call the core library to:
11223 // - invalidate dependent code of this prefix; 11223 // - invalidate dependent code of this prefix;
11224 // - mark this prefixes as loaded; 11224 // - mark this prefixes as loaded;
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after
12807 const intptr_t num_checks = NumberOfChecks(); 12807 const intptr_t num_checks = NumberOfChecks();
12808 return OS::SCreate(Thread::Current()->zone(), 12808 return OS::SCreate(Thread::Current()->zone(),
12809 "ICData target:'%s' num-args: %" Pd " num-checks: %" Pd "", 12809 "ICData target:'%s' num-args: %" Pd " num-checks: %" Pd "",
12810 name.ToCString(), num_args, num_checks); 12810 name.ToCString(), num_args, num_checks);
12811 } 12811 }
12812 12812
12813 12813
12814 RawFunction* ICData::Owner() const { 12814 RawFunction* ICData::Owner() const {
12815 Object& obj = Object::Handle(raw_ptr()->owner_); 12815 Object& obj = Object::Handle(raw_ptr()->owner_);
12816 if (obj.IsNull()) { 12816 if (obj.IsNull()) {
12817 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); 12817 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT);
12818 return Function::null(); 12818 return Function::null();
12819 } else if (obj.IsFunction()) { 12819 } else if (obj.IsFunction()) {
12820 return Function::Cast(obj).raw(); 12820 return Function::Cast(obj).raw();
12821 } else { 12821 } else {
12822 ICData& original = ICData::Handle(); 12822 ICData& original = ICData::Handle();
12823 original ^= obj.raw(); 12823 original ^= obj.raw();
12824 return original.Owner(); 12824 return original.Owner();
12825 } 12825 }
12826 } 12826 }
12827 12827
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
13995 13995
13996 13996
13997 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, 13997 RawTypedData* Code::GetDeoptInfoAtPc(uword pc,
13998 ICData::DeoptReasonId* deopt_reason, 13998 ICData::DeoptReasonId* deopt_reason,
13999 uint32_t* deopt_flags) const { 13999 uint32_t* deopt_flags) const {
14000 ASSERT(is_optimized()); 14000 ASSERT(is_optimized());
14001 const Instructions& instrs = Instructions::Handle(instructions()); 14001 const Instructions& instrs = Instructions::Handle(instructions());
14002 uword code_entry = instrs.PayloadStart(); 14002 uword code_entry = instrs.PayloadStart();
14003 const Array& table = Array::Handle(deopt_info_array()); 14003 const Array& table = Array::Handle(deopt_info_array());
14004 if (table.IsNull()) { 14004 if (table.IsNull()) {
14005 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); 14005 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT);
14006 return TypedData::null(); 14006 return TypedData::null();
14007 } 14007 }
14008 // Linear search for the PC offset matching the target PC. 14008 // Linear search for the PC offset matching the target PC.
14009 intptr_t length = DeoptTable::GetLength(table); 14009 intptr_t length = DeoptTable::GetLength(table);
14010 Smi& offset = Smi::Handle(); 14010 Smi& offset = Smi::Handle();
14011 Smi& reason_and_flags = Smi::Handle(); 14011 Smi& reason_and_flags = Smi::Handle();
14012 TypedData& info = TypedData::Handle(); 14012 TypedData& info = TypedData::Handle();
14013 for (intptr_t i = 0; i < length; ++i) { 14013 for (intptr_t i = 0; i < length; ++i) {
14014 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); 14014 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags);
14015 if (pc == (code_entry + offset.Value())) { 14015 if (pc == (code_entry + offset.Value())) {
(...skipping 9001 matching lines...) Expand 10 before | Expand all | Expand 10 after
23017 return UserTag::null(); 23017 return UserTag::null();
23018 } 23018 }
23019 23019
23020 23020
23021 const char* UserTag::ToCString() const { 23021 const char* UserTag::ToCString() const {
23022 const String& tag_label = String::Handle(label()); 23022 const String& tag_label = String::Handle(label());
23023 return tag_label.ToCString(); 23023 return tag_label.ToCString();
23024 } 23024 }
23025 23025
23026 } // namespace dart 23026 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/metrics_test.cc ('k') | runtime/vm/object_graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698