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/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 3408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3419 | 3419 |
3420 TokenPosition Class::ComputeEndTokenPos() const { | 3420 TokenPosition Class::ComputeEndTokenPos() const { |
3421 // Return the begin token for synthetic classes. | 3421 // Return the begin token for synthetic classes. |
3422 if (is_synthesized_class() || IsMixinApplication() || IsTopLevel()) { | 3422 if (is_synthesized_class() || IsMixinApplication() || IsTopLevel()) { |
3423 return token_pos(); | 3423 return token_pos(); |
3424 } | 3424 } |
3425 const Script& scr = Script::Handle(script()); | 3425 const Script& scr = Script::Handle(script()); |
3426 ASSERT(!scr.IsNull()); | 3426 ASSERT(!scr.IsNull()); |
3427 const TokenStream& tkns = TokenStream::Handle(scr.tokens()); | 3427 const TokenStream& tkns = TokenStream::Handle(scr.tokens()); |
3428 if (tkns.IsNull()) { | 3428 if (tkns.IsNull()) { |
3429 ASSERT(Dart::IsRunningPrecompiledCode()); | 3429 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
3430 return TokenPosition::kNoSource; | 3430 return TokenPosition::kNoSource; |
3431 } | 3431 } |
3432 TokenStream::Iterator tkit(tkns, | 3432 TokenStream::Iterator tkit(tkns, |
3433 token_pos(), | 3433 token_pos(), |
3434 TokenStream::Iterator::kNoNewlines); | 3434 TokenStream::Iterator::kNoNewlines); |
3435 intptr_t level = 0; | 3435 intptr_t level = 0; |
3436 while (tkit.CurrentTokenKind() != Token::kEOS) { | 3436 while (tkit.CurrentTokenKind() != Token::kEOS) { |
3437 if (tkit.CurrentTokenKind() == Token::kLBRACE) { | 3437 if (tkit.CurrentTokenKind() == Token::kLBRACE) { |
3438 level++; | 3438 level++; |
3439 } else if (tkit.CurrentTokenKind() == Token::kRBRACE) { | 3439 } else if (tkit.CurrentTokenKind() == Token::kRBRACE) { |
(...skipping 5375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8815 if (source.IsNull()) { | 8815 if (source.IsNull()) { |
8816 return GenerateSource(); | 8816 return GenerateSource(); |
8817 } | 8817 } |
8818 return raw_ptr()->source_; | 8818 return raw_ptr()->source_; |
8819 } | 8819 } |
8820 | 8820 |
8821 | 8821 |
8822 RawString* Script::GenerateSource() const { | 8822 RawString* Script::GenerateSource() const { |
8823 const TokenStream& token_stream = TokenStream::Handle(tokens()); | 8823 const TokenStream& token_stream = TokenStream::Handle(tokens()); |
8824 if (token_stream.IsNull()) { | 8824 if (token_stream.IsNull()) { |
8825 ASSERT(Dart::IsRunningPrecompiledCode()); | 8825 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
8826 return String::null(); | 8826 return String::null(); |
8827 } | 8827 } |
8828 return token_stream.GenerateSource(); | 8828 return token_stream.GenerateSource(); |
8829 } | 8829 } |
8830 | 8830 |
8831 | 8831 |
8832 RawGrowableObjectArray* Script::GenerateLineNumberArray() const { | 8832 RawGrowableObjectArray* Script::GenerateLineNumberArray() const { |
8833 Zone* zone = Thread::Current()->zone(); | 8833 Zone* zone = Thread::Current()->zone(); |
8834 const GrowableObjectArray& info = | 8834 const GrowableObjectArray& info = |
8835 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); | 8835 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8984 } | 8984 } |
8985 | 8985 |
8986 | 8986 |
8987 void Script::GetTokenLocation(TokenPosition token_pos, | 8987 void Script::GetTokenLocation(TokenPosition token_pos, |
8988 intptr_t* line, | 8988 intptr_t* line, |
8989 intptr_t* column, | 8989 intptr_t* column, |
8990 intptr_t* token_len) const { | 8990 intptr_t* token_len) const { |
8991 ASSERT(line != NULL); | 8991 ASSERT(line != NULL); |
8992 const TokenStream& tkns = TokenStream::Handle(tokens()); | 8992 const TokenStream& tkns = TokenStream::Handle(tokens()); |
8993 if (tkns.IsNull()) { | 8993 if (tkns.IsNull()) { |
8994 ASSERT(Dart::IsRunningPrecompiledCode()); | 8994 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
8995 *line = -1; | 8995 *line = -1; |
8996 if (column != NULL) { | 8996 if (column != NULL) { |
8997 *column = -1; | 8997 *column = -1; |
8998 } | 8998 } |
8999 if (token_len != NULL) { | 8999 if (token_len != NULL) { |
9000 *token_len = 1; | 9000 *token_len = 1; |
9001 } | 9001 } |
9002 return; | 9002 return; |
9003 } | 9003 } |
9004 if (column == NULL) { | 9004 if (column == NULL) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9083 end_pos = tkit.CurrentPosition(); | 9083 end_pos = tkit.CurrentPosition(); |
9084 tkit.Advance(); | 9084 tkit.Advance(); |
9085 } | 9085 } |
9086 *last_token_index = end_pos; | 9086 *last_token_index = end_pos; |
9087 } | 9087 } |
9088 | 9088 |
9089 | 9089 |
9090 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { | 9090 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { |
9091 const String& src = String::Handle(Source()); | 9091 const String& src = String::Handle(Source()); |
9092 if (src.IsNull()) { | 9092 if (src.IsNull()) { |
9093 ASSERT(Dart::IsRunningPrecompiledCode()); | 9093 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
9094 return Symbols::OptimizedOut().raw(); | 9094 return Symbols::OptimizedOut().raw(); |
9095 } | 9095 } |
9096 intptr_t relative_line_number = line_number - line_offset(); | 9096 intptr_t relative_line_number = line_number - line_offset(); |
9097 intptr_t current_line = 1; | 9097 intptr_t current_line = 1; |
9098 intptr_t line_start_idx = -1; | 9098 intptr_t line_start_idx = -1; |
9099 intptr_t last_char_idx = -1; | 9099 intptr_t last_char_idx = -1; |
9100 for (intptr_t ix = 0; | 9100 for (intptr_t ix = 0; |
9101 (ix < src.Length()) && (current_line <= relative_line_number); | 9101 (ix < src.Length()) && (current_line <= relative_line_number); |
9102 ix++) { | 9102 ix++) { |
9103 if ((current_line == relative_line_number) && (line_start_idx < 0)) { | 9103 if ((current_line == relative_line_number) && (line_start_idx < 0)) { |
(...skipping 21 matching lines...) Expand all Loading... |
9125 } | 9125 } |
9126 } | 9126 } |
9127 | 9127 |
9128 | 9128 |
9129 RawString* Script::GetSnippet(intptr_t from_line, | 9129 RawString* Script::GetSnippet(intptr_t from_line, |
9130 intptr_t from_column, | 9130 intptr_t from_column, |
9131 intptr_t to_line, | 9131 intptr_t to_line, |
9132 intptr_t to_column) const { | 9132 intptr_t to_column) const { |
9133 const String& src = String::Handle(Source()); | 9133 const String& src = String::Handle(Source()); |
9134 if (src.IsNull()) { | 9134 if (src.IsNull()) { |
9135 ASSERT(Dart::IsRunningPrecompiledCode()); | 9135 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
9136 return Symbols::OptimizedOut().raw(); | 9136 return Symbols::OptimizedOut().raw(); |
9137 } | 9137 } |
9138 intptr_t length = src.Length(); | 9138 intptr_t length = src.Length(); |
9139 intptr_t line = 1 + line_offset(); | 9139 intptr_t line = 1 + line_offset(); |
9140 intptr_t column = 1; | 9140 intptr_t column = 1; |
9141 intptr_t scan_position = 0; | 9141 intptr_t scan_position = 0; |
9142 intptr_t snippet_start = -1; | 9142 intptr_t snippet_start = -1; |
9143 intptr_t snippet_end = -1; | 9143 intptr_t snippet_end = -1; |
9144 if (from_line - line_offset() == 1) { | 9144 if (from_line - line_offset() == 1) { |
9145 column += col_offset(); | 9145 column += col_offset(); |
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10974 | 10974 |
10975 | 10975 |
10976 bool LibraryPrefix::LoadLibrary() const { | 10976 bool LibraryPrefix::LoadLibrary() const { |
10977 // Non-deferred prefixes are loaded. | 10977 // Non-deferred prefixes are loaded. |
10978 ASSERT(is_deferred_load() || is_loaded()); | 10978 ASSERT(is_deferred_load() || is_loaded()); |
10979 if (is_loaded()) { | 10979 if (is_loaded()) { |
10980 return true; // Load request has already completed. | 10980 return true; // Load request has already completed. |
10981 } | 10981 } |
10982 ASSERT(is_deferred_load()); | 10982 ASSERT(is_deferred_load()); |
10983 ASSERT(num_imports() == 1); | 10983 ASSERT(num_imports() == 1); |
10984 if (Dart::IsRunningPrecompiledCode()) { | 10984 if (Dart::snapshot_kind() == Snapshot::kAppNoJIT) { |
10985 // The library list was tree-shaken away. | 10985 // The library list was tree-shaken away. |
10986 this->set_is_loaded(); | 10986 this->set_is_loaded(); |
10987 return true; | 10987 return true; |
10988 } | 10988 } |
10989 // This is a prefix for a deferred library. If the library is not loaded | 10989 // This is a prefix for a deferred library. If the library is not loaded |
10990 // yet and isn't being loaded, call the library tag handler to schedule | 10990 // yet and isn't being loaded, call the library tag handler to schedule |
10991 // loading. Once all outstanding load requests have completed, the embedder | 10991 // loading. Once all outstanding load requests have completed, the embedder |
10992 // will call the core library to: | 10992 // will call the core library to: |
10993 // - invalidate dependent code of this prefix; | 10993 // - invalidate dependent code of this prefix; |
10994 // - mark this prefixes as loaded; | 10994 // - mark this prefixes as loaded; |
(...skipping 2548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13543 | 13543 |
13544 | 13544 |
13545 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, | 13545 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, |
13546 ICData::DeoptReasonId* deopt_reason, | 13546 ICData::DeoptReasonId* deopt_reason, |
13547 uint32_t* deopt_flags) const { | 13547 uint32_t* deopt_flags) const { |
13548 ASSERT(is_optimized()); | 13548 ASSERT(is_optimized()); |
13549 const Instructions& instrs = Instructions::Handle(instructions()); | 13549 const Instructions& instrs = Instructions::Handle(instructions()); |
13550 uword code_entry = instrs.EntryPoint(); | 13550 uword code_entry = instrs.EntryPoint(); |
13551 const Array& table = Array::Handle(deopt_info_array()); | 13551 const Array& table = Array::Handle(deopt_info_array()); |
13552 if (table.IsNull()) { | 13552 if (table.IsNull()) { |
13553 ASSERT(Dart::IsRunningPrecompiledCode()); | 13553 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
13554 return TypedData::null(); | 13554 return TypedData::null(); |
13555 } | 13555 } |
13556 // Linear search for the PC offset matching the target PC. | 13556 // Linear search for the PC offset matching the target PC. |
13557 intptr_t length = DeoptTable::GetLength(table); | 13557 intptr_t length = DeoptTable::GetLength(table); |
13558 Smi& offset = Smi::Handle(); | 13558 Smi& offset = Smi::Handle(); |
13559 Smi& reason_and_flags = Smi::Handle(); | 13559 Smi& reason_and_flags = Smi::Handle(); |
13560 TypedData& info = TypedData::Handle(); | 13560 TypedData& info = TypedData::Handle(); |
13561 for (intptr_t i = 0; i < length; ++i) { | 13561 for (intptr_t i = 0; i < length; ++i) { |
13562 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); | 13562 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); |
13563 if (pc == (code_entry + offset.Value())) { | 13563 if (pc == (code_entry + offset.Value())) { |
(...skipping 8818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22382 return UserTag::null(); | 22382 return UserTag::null(); |
22383 } | 22383 } |
22384 | 22384 |
22385 | 22385 |
22386 const char* UserTag::ToCString() const { | 22386 const char* UserTag::ToCString() const { |
22387 const String& tag_label = String::Handle(label()); | 22387 const String& tag_label = String::Handle(label()); |
22388 return tag_label.ToCString(); | 22388 return tag_label.ToCString(); |
22389 } | 22389 } |
22390 | 22390 |
22391 } // namespace dart | 22391 } // namespace dart |
OLD | NEW |