OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 template <class Source> | 30 template <class Source> |
31 Handle<String> Bootstrapper::SourceLookup(int index) { | 31 Handle<String> Bootstrapper::SourceLookup(int index) { |
32 DCHECK(0 <= index && index < Source::GetBuiltinsCount()); | 32 DCHECK(0 <= index && index < Source::GetBuiltinsCount()); |
33 Heap* heap = isolate_->heap(); | 33 Heap* heap = isolate_->heap(); |
34 if (Source::GetSourceCache(heap)->get(index)->IsUndefined()) { | 34 if (Source::GetSourceCache(heap)->get(index)->IsUndefined()) { |
35 // We can use external strings for the natives. | 35 // We can use external strings for the natives. |
36 Vector<const char> source = Source::GetScriptSource(index); | 36 Vector<const char> source = Source::GetScriptSource(index); |
37 NativesExternalStringResource* resource = | 37 NativesExternalStringResource* resource = |
38 new NativesExternalStringResource(source.start(), source.length()); | 38 new NativesExternalStringResource(source.start(), source.length()); |
39 // We do not expect this to throw an exception. Change this if it does. | 39 Handle<ExternalOneByteString> source_code = |
40 Handle<String> source_code = isolate_->factory() | 40 isolate_->factory()->NewNativeSourceString(resource); |
41 ->NewExternalStringFromOneByte(resource) | |
42 .ToHandleChecked(); | |
43 // Mark this external string with a special map. | 41 // Mark this external string with a special map. |
44 source_code->set_map(isolate_->heap()->native_source_string_map()); | 42 DCHECK(source_code->is_short()); |
45 Source::GetSourceCache(heap)->set(index, *source_code); | 43 Source::GetSourceCache(heap)->set(index, *source_code); |
46 } | 44 } |
47 Handle<Object> cached_source(Source::GetSourceCache(heap)->get(index), | 45 Handle<Object> cached_source(Source::GetSourceCache(heap)->get(index), |
48 isolate_); | 46 isolate_); |
49 return Handle<String>::cast(cached_source); | 47 return Handle<String>::cast(cached_source); |
50 } | 48 } |
51 | 49 |
52 | 50 |
53 template Handle<String> Bootstrapper::SourceLookup<Natives>(int index); | 51 template Handle<String> Bootstrapper::SourceLookup<Natives>(int index); |
54 template Handle<String> Bootstrapper::SourceLookup<ExperimentalNatives>( | 52 template Handle<String> Bootstrapper::SourceLookup<ExperimentalNatives>( |
(...skipping 3721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3776 } | 3774 } |
3777 | 3775 |
3778 | 3776 |
3779 // Called when the top-level V8 mutex is destroyed. | 3777 // Called when the top-level V8 mutex is destroyed. |
3780 void Bootstrapper::FreeThreadResources() { | 3778 void Bootstrapper::FreeThreadResources() { |
3781 DCHECK(!IsActive()); | 3779 DCHECK(!IsActive()); |
3782 } | 3780 } |
3783 | 3781 |
3784 } // namespace internal | 3782 } // namespace internal |
3785 } // namespace v8 | 3783 } // namespace v8 |
OLD | NEW |