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 3552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3563 if (largest_seen < function.end_token_pos()) { | 3563 if (largest_seen < function.end_token_pos()) { |
3564 largest_seen = function.end_token_pos(); | 3564 largest_seen = function.end_token_pos(); |
3565 } | 3565 } |
3566 } | 3566 } |
3567 } | 3567 } |
3568 return TokenPosition(largest_seen); | 3568 return TokenPosition(largest_seen); |
3569 } | 3569 } |
3570 | 3570 |
3571 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); | 3571 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); |
3572 if (tkns.IsNull()) { | 3572 if (tkns.IsNull()) { |
3573 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); | 3573 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kFullAOT); |
3574 return TokenPosition::kNoSource; | 3574 return TokenPosition::kNoSource; |
3575 } | 3575 } |
3576 TokenStream::Iterator tkit(zone, tkns, token_pos(), | 3576 TokenStream::Iterator tkit(zone, tkns, token_pos(), |
3577 TokenStream::Iterator::kNoNewlines); | 3577 TokenStream::Iterator::kNoNewlines); |
3578 intptr_t level = 0; | 3578 intptr_t level = 0; |
3579 while (tkit.CurrentTokenKind() != Token::kEOS) { | 3579 while (tkit.CurrentTokenKind() != Token::kEOS) { |
3580 if (tkit.CurrentTokenKind() == Token::kLBRACE) { | 3580 if (tkit.CurrentTokenKind() == Token::kLBRACE) { |
3581 level++; | 3581 level++; |
3582 } else if (tkit.CurrentTokenKind() == Token::kRBRACE) { | 3582 } else if (tkit.CurrentTokenKind() == Token::kRBRACE) { |
3583 if (--level == 0) { | 3583 if (--level == 0) { |
(...skipping 4365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7949 } | 7949 } |
7950 | 7950 |
7951 | 7951 |
7952 RawString* Field::InitializingExpression() const { | 7952 RawString* Field::InitializingExpression() const { |
7953 Thread* thread = Thread::Current(); | 7953 Thread* thread = Thread::Current(); |
7954 Zone* zone = thread->zone(); | 7954 Zone* zone = thread->zone(); |
7955 const class Script& scr = Script::Handle(zone, Script()); | 7955 const class Script& scr = Script::Handle(zone, Script()); |
7956 ASSERT(!scr.IsNull()); | 7956 ASSERT(!scr.IsNull()); |
7957 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); | 7957 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); |
7958 if (tkns.IsNull()) { | 7958 if (tkns.IsNull()) { |
7959 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); | 7959 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kFullAOT); |
7960 return String::null(); | 7960 return String::null(); |
7961 } | 7961 } |
7962 TokenStream::Iterator tkit(zone, tkns, token_pos()); | 7962 TokenStream::Iterator tkit(zone, tkns, token_pos()); |
7963 ASSERT(Token::IsIdentifier(tkit.CurrentTokenKind())); | 7963 ASSERT(Token::IsIdentifier(tkit.CurrentTokenKind())); |
7964 #if defined(DEBUG) | 7964 #if defined(DEBUG) |
7965 const String& literal = String::Handle(zone, tkit.CurrentLiteral()); | 7965 const String& literal = String::Handle(zone, tkit.CurrentLiteral()); |
7966 ASSERT(literal.raw() == name()); | 7966 ASSERT(literal.raw() == name()); |
7967 #endif | 7967 #endif |
7968 tkit.Advance(); | 7968 tkit.Advance(); |
7969 if (tkit.CurrentTokenKind() != Token::kASSIGN) { | 7969 if (tkit.CurrentTokenKind() != Token::kASSIGN) { |
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9102 | 9102 |
9103 | 9103 |
9104 RawString* Script::GenerateSource() const { | 9104 RawString* Script::GenerateSource() const { |
9105 if (kind() == RawScript::kKernelTag) { | 9105 if (kind() == RawScript::kKernelTag) { |
9106 // In kernel it's embedded. | 9106 // In kernel it's embedded. |
9107 return raw_ptr()->source_; | 9107 return raw_ptr()->source_; |
9108 } | 9108 } |
9109 | 9109 |
9110 const TokenStream& token_stream = TokenStream::Handle(tokens()); | 9110 const TokenStream& token_stream = TokenStream::Handle(tokens()); |
9111 if (token_stream.IsNull()) { | 9111 if (token_stream.IsNull()) { |
9112 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); | 9112 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kFullAOT); |
9113 return String::null(); | 9113 return String::null(); |
9114 } | 9114 } |
9115 return token_stream.GenerateSource(); | 9115 return token_stream.GenerateSource(); |
9116 } | 9116 } |
9117 | 9117 |
9118 | 9118 |
9119 void Script::set_compile_time_constants(const Array& value) const { | 9119 void Script::set_compile_time_constants(const Array& value) const { |
9120 StorePointer(&raw_ptr()->compile_time_constants_, value.raw()); | 9120 StorePointer(&raw_ptr()->compile_time_constants_, value.raw()); |
9121 } | 9121 } |
9122 | 9122 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9467 ++i) { | 9467 ++i) { |
9468 ++*token_len; | 9468 ++*token_len; |
9469 } | 9469 } |
9470 } | 9470 } |
9471 } | 9471 } |
9472 return; | 9472 return; |
9473 } | 9473 } |
9474 | 9474 |
9475 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); | 9475 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); |
9476 if (tkns.IsNull()) { | 9476 if (tkns.IsNull()) { |
9477 ASSERT((Dart::vm_snapshot_kind() == Snapshot::kAppAOT)); | 9477 ASSERT((Dart::vm_snapshot_kind() == Snapshot::kFullAOT)); |
9478 *line = -1; | 9478 *line = -1; |
9479 if (column != NULL) { | 9479 if (column != NULL) { |
9480 *column = -1; | 9480 *column = -1; |
9481 } | 9481 } |
9482 if (token_len != NULL) { | 9482 if (token_len != NULL) { |
9483 *token_len = 1; | 9483 *token_len = 1; |
9484 } | 9484 } |
9485 return; | 9485 return; |
9486 } | 9486 } |
9487 if (column == NULL) { | 9487 if (column == NULL) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9625 } | 9625 } |
9626 result = result & ((static_cast<uint32_t>(1) << 31) - 1); | 9626 result = result & ((static_cast<uint32_t>(1) << 31) - 1); |
9627 ASSERT(result <= static_cast<uint32_t>(kMaxInt32)); | 9627 ASSERT(result <= static_cast<uint32_t>(kMaxInt32)); |
9628 return result; | 9628 return result; |
9629 } | 9629 } |
9630 | 9630 |
9631 | 9631 |
9632 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { | 9632 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { |
9633 const String& src = String::Handle(Source()); | 9633 const String& src = String::Handle(Source()); |
9634 if (src.IsNull()) { | 9634 if (src.IsNull()) { |
9635 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); | 9635 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kFullAOT); |
9636 return Symbols::OptimizedOut().raw(); | 9636 return Symbols::OptimizedOut().raw(); |
9637 } | 9637 } |
9638 intptr_t relative_line_number = line_number - line_offset(); | 9638 intptr_t relative_line_number = line_number - line_offset(); |
9639 intptr_t current_line = 1; | 9639 intptr_t current_line = 1; |
9640 intptr_t line_start_idx = -1; | 9640 intptr_t line_start_idx = -1; |
9641 intptr_t last_char_idx = -1; | 9641 intptr_t last_char_idx = -1; |
9642 for (intptr_t ix = 0; | 9642 for (intptr_t ix = 0; |
9643 (ix < src.Length()) && (current_line <= relative_line_number); ix++) { | 9643 (ix < src.Length()) && (current_line <= relative_line_number); ix++) { |
9644 if ((current_line == relative_line_number) && (line_start_idx < 0)) { | 9644 if ((current_line == relative_line_number) && (line_start_idx < 0)) { |
9645 line_start_idx = ix; | 9645 line_start_idx = ix; |
(...skipping 29 matching lines...) Expand all Loading... |
9675 return GetSnippet(from_line, from_column, to_line, to_column); | 9675 return GetSnippet(from_line, from_column, to_line, to_column); |
9676 } | 9676 } |
9677 | 9677 |
9678 | 9678 |
9679 RawString* Script::GetSnippet(intptr_t from_line, | 9679 RawString* Script::GetSnippet(intptr_t from_line, |
9680 intptr_t from_column, | 9680 intptr_t from_column, |
9681 intptr_t to_line, | 9681 intptr_t to_line, |
9682 intptr_t to_column) const { | 9682 intptr_t to_column) const { |
9683 const String& src = String::Handle(Source()); | 9683 const String& src = String::Handle(Source()); |
9684 if (src.IsNull()) { | 9684 if (src.IsNull()) { |
9685 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); | 9685 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kFullAOT); |
9686 return Symbols::OptimizedOut().raw(); | 9686 return Symbols::OptimizedOut().raw(); |
9687 } | 9687 } |
9688 intptr_t length = src.Length(); | 9688 intptr_t length = src.Length(); |
9689 intptr_t line = 1 + line_offset(); | 9689 intptr_t line = 1 + line_offset(); |
9690 intptr_t column = 1; | 9690 intptr_t column = 1; |
9691 intptr_t scan_position = 0; | 9691 intptr_t scan_position = 0; |
9692 intptr_t snippet_start = -1; | 9692 intptr_t snippet_start = -1; |
9693 intptr_t snippet_end = -1; | 9693 intptr_t snippet_end = -1; |
9694 if (from_line - line_offset() == 1) { | 9694 if (from_line - line_offset() == 1) { |
9695 column += col_offset(); | 9695 column += col_offset(); |
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11572 | 11572 |
11573 | 11573 |
11574 bool LibraryPrefix::LoadLibrary() const { | 11574 bool LibraryPrefix::LoadLibrary() const { |
11575 // Non-deferred prefixes are loaded. | 11575 // Non-deferred prefixes are loaded. |
11576 ASSERT(is_deferred_load() || is_loaded()); | 11576 ASSERT(is_deferred_load() || is_loaded()); |
11577 if (is_loaded()) { | 11577 if (is_loaded()) { |
11578 return true; // Load request has already completed. | 11578 return true; // Load request has already completed. |
11579 } | 11579 } |
11580 ASSERT(is_deferred_load()); | 11580 ASSERT(is_deferred_load()); |
11581 ASSERT(num_imports() == 1); | 11581 ASSERT(num_imports() == 1); |
11582 if (Dart::vm_snapshot_kind() == Snapshot::kAppAOT) { | 11582 if (Dart::vm_snapshot_kind() == Snapshot::kFullAOT) { |
11583 // The library list was tree-shaken away. | 11583 // The library list was tree-shaken away. |
11584 this->set_is_loaded(); | 11584 this->set_is_loaded(); |
11585 return true; | 11585 return true; |
11586 } | 11586 } |
11587 // This is a prefix for a deferred library. If the library is not loaded | 11587 // This is a prefix for a deferred library. If the library is not loaded |
11588 // yet and isn't being loaded, call the library tag handler to schedule | 11588 // yet and isn't being loaded, call the library tag handler to schedule |
11589 // loading. Once all outstanding load requests have completed, the embedder | 11589 // loading. Once all outstanding load requests have completed, the embedder |
11590 // will call the core library to: | 11590 // will call the core library to: |
11591 // - invalidate dependent code of this prefix; | 11591 // - invalidate dependent code of this prefix; |
11592 // - mark this prefixes as loaded; | 11592 // - mark this prefixes as loaded; |
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13038 const intptr_t num_checks = NumberOfChecks(); | 13038 const intptr_t num_checks = NumberOfChecks(); |
13039 return OS::SCreate(Thread::Current()->zone(), | 13039 return OS::SCreate(Thread::Current()->zone(), |
13040 "ICData target:'%s' num-args: %" Pd " num-checks: %" Pd "", | 13040 "ICData target:'%s' num-args: %" Pd " num-checks: %" Pd "", |
13041 name.ToCString(), num_args, num_checks); | 13041 name.ToCString(), num_args, num_checks); |
13042 } | 13042 } |
13043 | 13043 |
13044 | 13044 |
13045 RawFunction* ICData::Owner() const { | 13045 RawFunction* ICData::Owner() const { |
13046 Object& obj = Object::Handle(raw_ptr()->owner_); | 13046 Object& obj = Object::Handle(raw_ptr()->owner_); |
13047 if (obj.IsNull()) { | 13047 if (obj.IsNull()) { |
13048 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); | 13048 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kFullAOT); |
13049 return Function::null(); | 13049 return Function::null(); |
13050 } else if (obj.IsFunction()) { | 13050 } else if (obj.IsFunction()) { |
13051 return Function::Cast(obj).raw(); | 13051 return Function::Cast(obj).raw(); |
13052 } else { | 13052 } else { |
13053 ICData& original = ICData::Handle(); | 13053 ICData& original = ICData::Handle(); |
13054 original ^= obj.raw(); | 13054 original ^= obj.raw(); |
13055 return original.Owner(); | 13055 return original.Owner(); |
13056 } | 13056 } |
13057 } | 13057 } |
13058 | 13058 |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14235 | 14235 |
14236 | 14236 |
14237 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, | 14237 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, |
14238 ICData::DeoptReasonId* deopt_reason, | 14238 ICData::DeoptReasonId* deopt_reason, |
14239 uint32_t* deopt_flags) const { | 14239 uint32_t* deopt_flags) const { |
14240 ASSERT(is_optimized()); | 14240 ASSERT(is_optimized()); |
14241 const Instructions& instrs = Instructions::Handle(instructions()); | 14241 const Instructions& instrs = Instructions::Handle(instructions()); |
14242 uword code_entry = instrs.PayloadStart(); | 14242 uword code_entry = instrs.PayloadStart(); |
14243 const Array& table = Array::Handle(deopt_info_array()); | 14243 const Array& table = Array::Handle(deopt_info_array()); |
14244 if (table.IsNull()) { | 14244 if (table.IsNull()) { |
14245 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kAppAOT); | 14245 ASSERT(Dart::vm_snapshot_kind() == Snapshot::kFullAOT); |
14246 return TypedData::null(); | 14246 return TypedData::null(); |
14247 } | 14247 } |
14248 // Linear search for the PC offset matching the target PC. | 14248 // Linear search for the PC offset matching the target PC. |
14249 intptr_t length = DeoptTable::GetLength(table); | 14249 intptr_t length = DeoptTable::GetLength(table); |
14250 Smi& offset = Smi::Handle(); | 14250 Smi& offset = Smi::Handle(); |
14251 Smi& reason_and_flags = Smi::Handle(); | 14251 Smi& reason_and_flags = Smi::Handle(); |
14252 TypedData& info = TypedData::Handle(); | 14252 TypedData& info = TypedData::Handle(); |
14253 for (intptr_t i = 0; i < length; ++i) { | 14253 for (intptr_t i = 0; i < length; ++i) { |
14254 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); | 14254 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); |
14255 if (pc == (code_entry + offset.Value())) { | 14255 if (pc == (code_entry + offset.Value())) { |
(...skipping 9097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
23353 return UserTag::null(); | 23353 return UserTag::null(); |
23354 } | 23354 } |
23355 | 23355 |
23356 | 23356 |
23357 const char* UserTag::ToCString() const { | 23357 const char* UserTag::ToCString() const { |
23358 const String& tag_label = String::Handle(label()); | 23358 const String& tag_label = String::Handle(label()); |
23359 return tag_label.ToCString(); | 23359 return tag_label.ToCString(); |
23360 } | 23360 } |
23361 | 23361 |
23362 } // namespace dart | 23362 } // namespace dart |
OLD | NEW |