OLD | NEW |
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 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 cls = isolate->class_table()->At(kFreeListElement); | 1043 cls = isolate->class_table()->At(kFreeListElement); |
1044 cls.set_name(Symbols::FreeListElement()); | 1044 cls.set_name(Symbols::FreeListElement()); |
1045 cls = isolate->class_table()->At(kForwardingCorpse); | 1045 cls = isolate->class_table()->At(kForwardingCorpse); |
1046 cls.set_name(Symbols::ForwardingCorpse()); | 1046 cls.set_name(Symbols::ForwardingCorpse()); |
1047 | 1047 |
1048 { | 1048 { |
1049 ASSERT(isolate == Dart::vm_isolate()); | 1049 ASSERT(isolate == Dart::vm_isolate()); |
1050 WritableVMIsolateScope scope(Thread::Current()); | 1050 WritableVMIsolateScope scope(Thread::Current()); |
1051 PremarkingVisitor premarker; | 1051 PremarkingVisitor premarker; |
1052 ASSERT(isolate->heap()->UsedInWords(Heap::kNew) == 0); | 1052 ASSERT(isolate->heap()->UsedInWords(Heap::kNew) == 0); |
1053 isolate->heap()->IterateOldObjectsNoEmbedderPages(&premarker); | 1053 isolate->heap()->IterateOldObjectsNoExternalPages(&premarker); |
1054 // Make the VM isolate read-only again after setting all objects as marked. | 1054 // Make the VM isolate read-only again after setting all objects as marked. |
1055 } | 1055 } |
1056 } | 1056 } |
1057 | 1057 |
1058 | 1058 |
1059 void Object::set_vm_isolate_snapshot_object_table(const Array& table) { | 1059 void Object::set_vm_isolate_snapshot_object_table(const Array& table) { |
1060 ASSERT(Isolate::Current() == Dart::vm_isolate()); | 1060 ASSERT(Isolate::Current() == Dart::vm_isolate()); |
1061 *vm_isolate_snapshot_object_table_ = table.raw(); | 1061 *vm_isolate_snapshot_object_table_ = table.raw(); |
1062 } | 1062 } |
1063 | 1063 |
(...skipping 2429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3493 if (largest_seen < function.end_token_pos()) { | 3493 if (largest_seen < function.end_token_pos()) { |
3494 largest_seen = function.end_token_pos(); | 3494 largest_seen = function.end_token_pos(); |
3495 } | 3495 } |
3496 } | 3496 } |
3497 } | 3497 } |
3498 return TokenPosition(largest_seen); | 3498 return TokenPosition(largest_seen); |
3499 } | 3499 } |
3500 | 3500 |
3501 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); | 3501 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); |
3502 if (tkns.IsNull()) { | 3502 if (tkns.IsNull()) { |
3503 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); | 3503 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); |
3504 return TokenPosition::kNoSource; | 3504 return TokenPosition::kNoSource; |
3505 } | 3505 } |
3506 TokenStream::Iterator tkit(zone, tkns, token_pos(), | 3506 TokenStream::Iterator tkit(zone, tkns, token_pos(), |
3507 TokenStream::Iterator::kNoNewlines); | 3507 TokenStream::Iterator::kNoNewlines); |
3508 intptr_t level = 0; | 3508 intptr_t level = 0; |
3509 while (tkit.CurrentTokenKind() != Token::kEOS) { | 3509 while (tkit.CurrentTokenKind() != Token::kEOS) { |
3510 if (tkit.CurrentTokenKind() == Token::kLBRACE) { | 3510 if (tkit.CurrentTokenKind() == Token::kLBRACE) { |
3511 level++; | 3511 level++; |
3512 } else if (tkit.CurrentTokenKind() == Token::kRBRACE) { | 3512 } else if (tkit.CurrentTokenKind() == Token::kRBRACE) { |
3513 if (--level == 0) { | 3513 if (--level == 0) { |
(...skipping 4140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7654 } | 7654 } |
7655 | 7655 |
7656 | 7656 |
7657 RawString* Field::InitializingExpression() const { | 7657 RawString* Field::InitializingExpression() const { |
7658 Thread* thread = Thread::Current(); | 7658 Thread* thread = Thread::Current(); |
7659 Zone* zone = thread->zone(); | 7659 Zone* zone = thread->zone(); |
7660 const class Script& scr = Script::Handle(zone, Script()); | 7660 const class Script& scr = Script::Handle(zone, Script()); |
7661 ASSERT(!scr.IsNull()); | 7661 ASSERT(!scr.IsNull()); |
7662 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); | 7662 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); |
7663 if (tkns.IsNull()) { | 7663 if (tkns.IsNull()) { |
7664 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); | 7664 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); |
7665 return String::null(); | 7665 return String::null(); |
7666 } | 7666 } |
7667 TokenStream::Iterator tkit(zone, tkns, token_pos()); | 7667 TokenStream::Iterator tkit(zone, tkns, token_pos()); |
7668 ASSERT(Token::IsIdentifier(tkit.CurrentTokenKind())); | 7668 ASSERT(Token::IsIdentifier(tkit.CurrentTokenKind())); |
7669 #if defined(DEBUG) | 7669 #if defined(DEBUG) |
7670 const String& literal = String::Handle(zone, tkit.CurrentLiteral()); | 7670 const String& literal = String::Handle(zone, tkit.CurrentLiteral()); |
7671 ASSERT(literal.raw() == name()); | 7671 ASSERT(literal.raw() == name()); |
7672 #endif | 7672 #endif |
7673 tkit.Advance(); | 7673 tkit.Advance(); |
7674 if (tkit.CurrentTokenKind() != Token::kASSIGN) { | 7674 if (tkit.CurrentTokenKind() != Token::kASSIGN) { |
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8807 | 8807 |
8808 | 8808 |
8809 RawString* Script::GenerateSource() const { | 8809 RawString* Script::GenerateSource() const { |
8810 if (kind() == RawScript::kKernelTag) { | 8810 if (kind() == RawScript::kKernelTag) { |
8811 // In kernel it's embedded. | 8811 // In kernel it's embedded. |
8812 return raw_ptr()->source_; | 8812 return raw_ptr()->source_; |
8813 } | 8813 } |
8814 | 8814 |
8815 const TokenStream& token_stream = TokenStream::Handle(tokens()); | 8815 const TokenStream& token_stream = TokenStream::Handle(tokens()); |
8816 if (token_stream.IsNull()) { | 8816 if (token_stream.IsNull()) { |
8817 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); | 8817 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); |
8818 return String::null(); | 8818 return String::null(); |
8819 } | 8819 } |
8820 return token_stream.GenerateSource(); | 8820 return token_stream.GenerateSource(); |
8821 } | 8821 } |
8822 | 8822 |
8823 | 8823 |
8824 void Script::set_compile_time_constants(const Array& value) const { | 8824 void Script::set_compile_time_constants(const Array& value) const { |
8825 StorePointer(&raw_ptr()->compile_time_constants_, value.raw()); | 8825 StorePointer(&raw_ptr()->compile_time_constants_, value.raw()); |
8826 } | 8826 } |
8827 | 8827 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9064 *column = offset - smi.Value() + 1; | 9064 *column = offset - smi.Value() + 1; |
9065 } | 9065 } |
9066 if (token_len != NULL) { | 9066 if (token_len != NULL) { |
9067 *token_len = 1; | 9067 *token_len = 1; |
9068 } | 9068 } |
9069 return; | 9069 return; |
9070 } | 9070 } |
9071 | 9071 |
9072 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); | 9072 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); |
9073 if (tkns.IsNull()) { | 9073 if (tkns.IsNull()) { |
9074 ASSERT((Dart::snapshot_kind() == Snapshot::kAppAOT)); | 9074 ASSERT((Dart::vm_snapshot_kind() == Snapshot::kAppAOT)); |
9075 *line = -1; | 9075 *line = -1; |
9076 if (column != NULL) { | 9076 if (column != NULL) { |
9077 *column = -1; | 9077 *column = -1; |
9078 } | 9078 } |
9079 if (token_len != NULL) { | 9079 if (token_len != NULL) { |
9080 *token_len = 1; | 9080 *token_len = 1; |
9081 } | 9081 } |
9082 return; | 9082 return; |
9083 } | 9083 } |
9084 if (column == NULL) { | 9084 if (column == NULL) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9222 } | 9222 } |
9223 result = result & ((static_cast<uint32_t>(1) << 31) - 1); | 9223 result = result & ((static_cast<uint32_t>(1) << 31) - 1); |
9224 ASSERT(result <= static_cast<uint32_t>(kMaxInt32)); | 9224 ASSERT(result <= static_cast<uint32_t>(kMaxInt32)); |
9225 return result; | 9225 return result; |
9226 } | 9226 } |
9227 | 9227 |
9228 | 9228 |
9229 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { | 9229 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { |
9230 const String& src = String::Handle(Source()); | 9230 const String& src = String::Handle(Source()); |
9231 if (src.IsNull()) { | 9231 if (src.IsNull()) { |
9232 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); | 9232 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); |
9233 return Symbols::OptimizedOut().raw(); | 9233 return Symbols::OptimizedOut().raw(); |
9234 } | 9234 } |
9235 intptr_t relative_line_number = line_number - line_offset(); | 9235 intptr_t relative_line_number = line_number - line_offset(); |
9236 intptr_t current_line = 1; | 9236 intptr_t current_line = 1; |
9237 intptr_t line_start_idx = -1; | 9237 intptr_t line_start_idx = -1; |
9238 intptr_t last_char_idx = -1; | 9238 intptr_t last_char_idx = -1; |
9239 for (intptr_t ix = 0; | 9239 for (intptr_t ix = 0; |
9240 (ix < src.Length()) && (current_line <= relative_line_number); ix++) { | 9240 (ix < src.Length()) && (current_line <= relative_line_number); ix++) { |
9241 if ((current_line == relative_line_number) && (line_start_idx < 0)) { | 9241 if ((current_line == relative_line_number) && (line_start_idx < 0)) { |
9242 line_start_idx = ix; | 9242 line_start_idx = ix; |
(...skipping 29 matching lines...) Expand all Loading... |
9272 return GetSnippet(from_line, from_column, to_line, to_column); | 9272 return GetSnippet(from_line, from_column, to_line, to_column); |
9273 } | 9273 } |
9274 | 9274 |
9275 | 9275 |
9276 RawString* Script::GetSnippet(intptr_t from_line, | 9276 RawString* Script::GetSnippet(intptr_t from_line, |
9277 intptr_t from_column, | 9277 intptr_t from_column, |
9278 intptr_t to_line, | 9278 intptr_t to_line, |
9279 intptr_t to_column) const { | 9279 intptr_t to_column) const { |
9280 const String& src = String::Handle(Source()); | 9280 const String& src = String::Handle(Source()); |
9281 if (src.IsNull()) { | 9281 if (src.IsNull()) { |
9282 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); | 9282 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); |
9283 return Symbols::OptimizedOut().raw(); | 9283 return Symbols::OptimizedOut().raw(); |
9284 } | 9284 } |
9285 intptr_t length = src.Length(); | 9285 intptr_t length = src.Length(); |
9286 intptr_t line = 1 + line_offset(); | 9286 intptr_t line = 1 + line_offset(); |
9287 intptr_t column = 1; | 9287 intptr_t column = 1; |
9288 intptr_t scan_position = 0; | 9288 intptr_t scan_position = 0; |
9289 intptr_t snippet_start = -1; | 9289 intptr_t snippet_start = -1; |
9290 intptr_t snippet_end = -1; | 9290 intptr_t snippet_end = -1; |
9291 if (from_line - line_offset() == 1) { | 9291 if (from_line - line_offset() == 1) { |
9292 column += col_offset(); | 9292 column += col_offset(); |
(...skipping 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11186 | 11186 |
11187 | 11187 |
11188 bool LibraryPrefix::LoadLibrary() const { | 11188 bool LibraryPrefix::LoadLibrary() const { |
11189 // Non-deferred prefixes are loaded. | 11189 // Non-deferred prefixes are loaded. |
11190 ASSERT(is_deferred_load() || is_loaded()); | 11190 ASSERT(is_deferred_load() || is_loaded()); |
11191 if (is_loaded()) { | 11191 if (is_loaded()) { |
11192 return true; // Load request has already completed. | 11192 return true; // Load request has already completed. |
11193 } | 11193 } |
11194 ASSERT(is_deferred_load()); | 11194 ASSERT(is_deferred_load()); |
11195 ASSERT(num_imports() == 1); | 11195 ASSERT(num_imports() == 1); |
11196 if (Dart::snapshot_kind() == Snapshot::kAppAOT) { | 11196 if (Dart::vm_snapshot_kind() == Snapshot::kAppAOT) { |
11197 // The library list was tree-shaken away. | 11197 // The library list was tree-shaken away. |
11198 this->set_is_loaded(); | 11198 this->set_is_loaded(); |
11199 return true; | 11199 return true; |
11200 } | 11200 } |
11201 // This is a prefix for a deferred library. If the library is not loaded | 11201 // This is a prefix for a deferred library. If the library is not loaded |
11202 // yet and isn't being loaded, call the library tag handler to schedule | 11202 // yet and isn't being loaded, call the library tag handler to schedule |
11203 // loading. Once all outstanding load requests have completed, the embedder | 11203 // loading. Once all outstanding load requests have completed, the embedder |
11204 // will call the core library to: | 11204 // will call the core library to: |
11205 // - invalidate dependent code of this prefix; | 11205 // - invalidate dependent code of this prefix; |
11206 // - mark this prefixes as loaded; | 11206 // - mark this prefixes as loaded; |
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12789 const intptr_t num_checks = NumberOfChecks(); | 12789 const intptr_t num_checks = NumberOfChecks(); |
12790 return OS::SCreate(Thread::Current()->zone(), | 12790 return OS::SCreate(Thread::Current()->zone(), |
12791 "ICData target:'%s' num-args: %" Pd " num-checks: %" Pd "", | 12791 "ICData target:'%s' num-args: %" Pd " num-checks: %" Pd "", |
12792 name.ToCString(), num_args, num_checks); | 12792 name.ToCString(), num_args, num_checks); |
12793 } | 12793 } |
12794 | 12794 |
12795 | 12795 |
12796 RawFunction* ICData::Owner() const { | 12796 RawFunction* ICData::Owner() const { |
12797 Object& obj = Object::Handle(raw_ptr()->owner_); | 12797 Object& obj = Object::Handle(raw_ptr()->owner_); |
12798 if (obj.IsNull()) { | 12798 if (obj.IsNull()) { |
12799 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); | 12799 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); |
12800 return Function::null(); | 12800 return Function::null(); |
12801 } else if (obj.IsFunction()) { | 12801 } else if (obj.IsFunction()) { |
12802 return Function::Cast(obj).raw(); | 12802 return Function::Cast(obj).raw(); |
12803 } else { | 12803 } else { |
12804 ICData& original = ICData::Handle(); | 12804 ICData& original = ICData::Handle(); |
12805 original ^= obj.raw(); | 12805 original ^= obj.raw(); |
12806 return original.Owner(); | 12806 return original.Owner(); |
12807 } | 12807 } |
12808 } | 12808 } |
12809 | 12809 |
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13977 | 13977 |
13978 | 13978 |
13979 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, | 13979 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, |
13980 ICData::DeoptReasonId* deopt_reason, | 13980 ICData::DeoptReasonId* deopt_reason, |
13981 uint32_t* deopt_flags) const { | 13981 uint32_t* deopt_flags) const { |
13982 ASSERT(is_optimized()); | 13982 ASSERT(is_optimized()); |
13983 const Instructions& instrs = Instructions::Handle(instructions()); | 13983 const Instructions& instrs = Instructions::Handle(instructions()); |
13984 uword code_entry = instrs.PayloadStart(); | 13984 uword code_entry = instrs.PayloadStart(); |
13985 const Array& table = Array::Handle(deopt_info_array()); | 13985 const Array& table = Array::Handle(deopt_info_array()); |
13986 if (table.IsNull()) { | 13986 if (table.IsNull()) { |
13987 ASSERT(Dart::snapshot_kind() == Snapshot::kAppAOT); | 13987 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); |
13988 return TypedData::null(); | 13988 return TypedData::null(); |
13989 } | 13989 } |
13990 // Linear search for the PC offset matching the target PC. | 13990 // Linear search for the PC offset matching the target PC. |
13991 intptr_t length = DeoptTable::GetLength(table); | 13991 intptr_t length = DeoptTable::GetLength(table); |
13992 Smi& offset = Smi::Handle(); | 13992 Smi& offset = Smi::Handle(); |
13993 Smi& reason_and_flags = Smi::Handle(); | 13993 Smi& reason_and_flags = Smi::Handle(); |
13994 TypedData& info = TypedData::Handle(); | 13994 TypedData& info = TypedData::Handle(); |
13995 for (intptr_t i = 0; i < length; ++i) { | 13995 for (intptr_t i = 0; i < length; ++i) { |
13996 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); | 13996 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); |
13997 if (pc == (code_entry + offset.Value())) { | 13997 if (pc == (code_entry + offset.Value())) { |
(...skipping 9001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22999 return UserTag::null(); | 22999 return UserTag::null(); |
23000 } | 23000 } |
23001 | 23001 |
23002 | 23002 |
23003 const char* UserTag::ToCString() const { | 23003 const char* UserTag::ToCString() const { |
23004 const String& tag_label = String::Handle(label()); | 23004 const String& tag_label = String::Handle(label()); |
23005 return tag_label.ToCString(); | 23005 return tag_label.ToCString(); |
23006 } | 23006 } |
23007 | 23007 |
23008 } // namespace dart | 23008 } // namespace dart |
OLD | NEW |