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 3409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Zone* zone = Thread::Current()->zone(); | 3425 Zone* zone = Thread::Current()->zone(); |
3426 const Script& scr = Script::Handle(zone, script()); | 3426 const Script& scr = Script::Handle(zone, script()); |
3427 ASSERT(!scr.IsNull()); | 3427 ASSERT(!scr.IsNull()); |
3428 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); | 3428 const TokenStream& tkns = TokenStream::Handle(zone, scr.tokens()); |
3429 if (tkns.IsNull()) { | 3429 if (tkns.IsNull()) { |
3430 ASSERT(Dart::IsRunningPrecompiledCode()); | 3430 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
3431 return TokenPosition::kNoSource; | 3431 return TokenPosition::kNoSource; |
3432 } | 3432 } |
3433 TokenStream::Iterator tkit(zone, | 3433 TokenStream::Iterator tkit(zone, |
3434 tkns, | 3434 tkns, |
3435 token_pos(), | 3435 token_pos(), |
3436 TokenStream::Iterator::kNoNewlines); | 3436 TokenStream::Iterator::kNoNewlines); |
3437 intptr_t level = 0; | 3437 intptr_t level = 0; |
3438 while (tkit.CurrentTokenKind() != Token::kEOS) { | 3438 while (tkit.CurrentTokenKind() != Token::kEOS) { |
3439 if (tkit.CurrentTokenKind() == Token::kLBRACE) { | 3439 if (tkit.CurrentTokenKind() == Token::kLBRACE) { |
3440 level++; | 3440 level++; |
(...skipping 5348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8789 if (source.IsNull()) { | 8789 if (source.IsNull()) { |
8790 return GenerateSource(); | 8790 return GenerateSource(); |
8791 } | 8791 } |
8792 return raw_ptr()->source_; | 8792 return raw_ptr()->source_; |
8793 } | 8793 } |
8794 | 8794 |
8795 | 8795 |
8796 RawString* Script::GenerateSource() const { | 8796 RawString* Script::GenerateSource() const { |
8797 const TokenStream& token_stream = TokenStream::Handle(tokens()); | 8797 const TokenStream& token_stream = TokenStream::Handle(tokens()); |
8798 if (token_stream.IsNull()) { | 8798 if (token_stream.IsNull()) { |
8799 ASSERT(Dart::IsRunningPrecompiledCode()); | 8799 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
8800 return String::null(); | 8800 return String::null(); |
8801 } | 8801 } |
8802 return token_stream.GenerateSource(); | 8802 return token_stream.GenerateSource(); |
8803 } | 8803 } |
8804 | 8804 |
8805 | 8805 |
8806 RawGrowableObjectArray* Script::GenerateLineNumberArray() const { | 8806 RawGrowableObjectArray* Script::GenerateLineNumberArray() const { |
8807 Zone* zone = Thread::Current()->zone(); | 8807 Zone* zone = Thread::Current()->zone(); |
8808 const GrowableObjectArray& info = | 8808 const GrowableObjectArray& info = |
8809 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); | 8809 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8960 | 8960 |
8961 | 8961 |
8962 void Script::GetTokenLocation(TokenPosition token_pos, | 8962 void Script::GetTokenLocation(TokenPosition token_pos, |
8963 intptr_t* line, | 8963 intptr_t* line, |
8964 intptr_t* column, | 8964 intptr_t* column, |
8965 intptr_t* token_len) const { | 8965 intptr_t* token_len) const { |
8966 ASSERT(line != NULL); | 8966 ASSERT(line != NULL); |
8967 Zone* zone = Thread::Current()->zone(); | 8967 Zone* zone = Thread::Current()->zone(); |
8968 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); | 8968 const TokenStream& tkns = TokenStream::Handle(zone, tokens()); |
8969 if (tkns.IsNull()) { | 8969 if (tkns.IsNull()) { |
8970 ASSERT(Dart::IsRunningPrecompiledCode()); | 8970 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
8971 *line = -1; | 8971 *line = -1; |
8972 if (column != NULL) { | 8972 if (column != NULL) { |
8973 *column = -1; | 8973 *column = -1; |
8974 } | 8974 } |
8975 if (token_len != NULL) { | 8975 if (token_len != NULL) { |
8976 *token_len = 1; | 8976 *token_len = 1; |
8977 } | 8977 } |
8978 return; | 8978 return; |
8979 } | 8979 } |
8980 if (column == NULL) { | 8980 if (column == NULL) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9062 end_pos = tkit.CurrentPosition(); | 9062 end_pos = tkit.CurrentPosition(); |
9063 tkit.Advance(); | 9063 tkit.Advance(); |
9064 } | 9064 } |
9065 *last_token_index = end_pos; | 9065 *last_token_index = end_pos; |
9066 } | 9066 } |
9067 | 9067 |
9068 | 9068 |
9069 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { | 9069 RawString* Script::GetLine(intptr_t line_number, Heap::Space space) const { |
9070 const String& src = String::Handle(Source()); | 9070 const String& src = String::Handle(Source()); |
9071 if (src.IsNull()) { | 9071 if (src.IsNull()) { |
9072 ASSERT(Dart::IsRunningPrecompiledCode()); | 9072 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
9073 return Symbols::OptimizedOut().raw(); | 9073 return Symbols::OptimizedOut().raw(); |
9074 } | 9074 } |
9075 intptr_t relative_line_number = line_number - line_offset(); | 9075 intptr_t relative_line_number = line_number - line_offset(); |
9076 intptr_t current_line = 1; | 9076 intptr_t current_line = 1; |
9077 intptr_t line_start_idx = -1; | 9077 intptr_t line_start_idx = -1; |
9078 intptr_t last_char_idx = -1; | 9078 intptr_t last_char_idx = -1; |
9079 for (intptr_t ix = 0; | 9079 for (intptr_t ix = 0; |
9080 (ix < src.Length()) && (current_line <= relative_line_number); | 9080 (ix < src.Length()) && (current_line <= relative_line_number); |
9081 ix++) { | 9081 ix++) { |
9082 if ((current_line == relative_line_number) && (line_start_idx < 0)) { | 9082 if ((current_line == relative_line_number) && (line_start_idx < 0)) { |
(...skipping 21 matching lines...) Expand all Loading... |
9104 } | 9104 } |
9105 } | 9105 } |
9106 | 9106 |
9107 | 9107 |
9108 RawString* Script::GetSnippet(intptr_t from_line, | 9108 RawString* Script::GetSnippet(intptr_t from_line, |
9109 intptr_t from_column, | 9109 intptr_t from_column, |
9110 intptr_t to_line, | 9110 intptr_t to_line, |
9111 intptr_t to_column) const { | 9111 intptr_t to_column) const { |
9112 const String& src = String::Handle(Source()); | 9112 const String& src = String::Handle(Source()); |
9113 if (src.IsNull()) { | 9113 if (src.IsNull()) { |
9114 ASSERT(Dart::IsRunningPrecompiledCode()); | 9114 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
9115 return Symbols::OptimizedOut().raw(); | 9115 return Symbols::OptimizedOut().raw(); |
9116 } | 9116 } |
9117 intptr_t length = src.Length(); | 9117 intptr_t length = src.Length(); |
9118 intptr_t line = 1 + line_offset(); | 9118 intptr_t line = 1 + line_offset(); |
9119 intptr_t column = 1; | 9119 intptr_t column = 1; |
9120 intptr_t scan_position = 0; | 9120 intptr_t scan_position = 0; |
9121 intptr_t snippet_start = -1; | 9121 intptr_t snippet_start = -1; |
9122 intptr_t snippet_end = -1; | 9122 intptr_t snippet_end = -1; |
9123 if (from_line - line_offset() == 1) { | 9123 if (from_line - line_offset() == 1) { |
9124 column += col_offset(); | 9124 column += col_offset(); |
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10953 | 10953 |
10954 | 10954 |
10955 bool LibraryPrefix::LoadLibrary() const { | 10955 bool LibraryPrefix::LoadLibrary() const { |
10956 // Non-deferred prefixes are loaded. | 10956 // Non-deferred prefixes are loaded. |
10957 ASSERT(is_deferred_load() || is_loaded()); | 10957 ASSERT(is_deferred_load() || is_loaded()); |
10958 if (is_loaded()) { | 10958 if (is_loaded()) { |
10959 return true; // Load request has already completed. | 10959 return true; // Load request has already completed. |
10960 } | 10960 } |
10961 ASSERT(is_deferred_load()); | 10961 ASSERT(is_deferred_load()); |
10962 ASSERT(num_imports() == 1); | 10962 ASSERT(num_imports() == 1); |
10963 if (Dart::IsRunningPrecompiledCode()) { | 10963 if (Dart::snapshot_kind() == Snapshot::kAppNoJIT) { |
10964 // The library list was tree-shaken away. | 10964 // The library list was tree-shaken away. |
10965 this->set_is_loaded(); | 10965 this->set_is_loaded(); |
10966 return true; | 10966 return true; |
10967 } | 10967 } |
10968 // This is a prefix for a deferred library. If the library is not loaded | 10968 // This is a prefix for a deferred library. If the library is not loaded |
10969 // yet and isn't being loaded, call the library tag handler to schedule | 10969 // yet and isn't being loaded, call the library tag handler to schedule |
10970 // loading. Once all outstanding load requests have completed, the embedder | 10970 // loading. Once all outstanding load requests have completed, the embedder |
10971 // will call the core library to: | 10971 // will call the core library to: |
10972 // - invalidate dependent code of this prefix; | 10972 // - invalidate dependent code of this prefix; |
10973 // - mark this prefixes as loaded; | 10973 // - mark this prefixes as loaded; |
(...skipping 2548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13522 | 13522 |
13523 | 13523 |
13524 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, | 13524 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, |
13525 ICData::DeoptReasonId* deopt_reason, | 13525 ICData::DeoptReasonId* deopt_reason, |
13526 uint32_t* deopt_flags) const { | 13526 uint32_t* deopt_flags) const { |
13527 ASSERT(is_optimized()); | 13527 ASSERT(is_optimized()); |
13528 const Instructions& instrs = Instructions::Handle(instructions()); | 13528 const Instructions& instrs = Instructions::Handle(instructions()); |
13529 uword code_entry = instrs.EntryPoint(); | 13529 uword code_entry = instrs.EntryPoint(); |
13530 const Array& table = Array::Handle(deopt_info_array()); | 13530 const Array& table = Array::Handle(deopt_info_array()); |
13531 if (table.IsNull()) { | 13531 if (table.IsNull()) { |
13532 ASSERT(Dart::IsRunningPrecompiledCode()); | 13532 ASSERT(Dart::snapshot_kind() == Snapshot::kAppNoJIT); |
13533 return TypedData::null(); | 13533 return TypedData::null(); |
13534 } | 13534 } |
13535 // Linear search for the PC offset matching the target PC. | 13535 // Linear search for the PC offset matching the target PC. |
13536 intptr_t length = DeoptTable::GetLength(table); | 13536 intptr_t length = DeoptTable::GetLength(table); |
13537 Smi& offset = Smi::Handle(); | 13537 Smi& offset = Smi::Handle(); |
13538 Smi& reason_and_flags = Smi::Handle(); | 13538 Smi& reason_and_flags = Smi::Handle(); |
13539 TypedData& info = TypedData::Handle(); | 13539 TypedData& info = TypedData::Handle(); |
13540 for (intptr_t i = 0; i < length; ++i) { | 13540 for (intptr_t i = 0; i < length; ++i) { |
13541 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); | 13541 DeoptTable::GetEntry(table, i, &offset, &info, &reason_and_flags); |
13542 if (pc == (code_entry + offset.Value())) { | 13542 if (pc == (code_entry + offset.Value())) { |
(...skipping 8852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22395 return UserTag::null(); | 22395 return UserTag::null(); |
22396 } | 22396 } |
22397 | 22397 |
22398 | 22398 |
22399 const char* UserTag::ToCString() const { | 22399 const char* UserTag::ToCString() const { |
22400 const String& tag_label = String::Handle(label()); | 22400 const String& tag_label = String::Handle(label()); |
22401 return tag_label.ToCString(); | 22401 return tag_label.ToCString(); |
22402 } | 22402 } |
22403 | 22403 |
22404 } // namespace dart | 22404 } // namespace dart |
OLD | NEW |