Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Side by Side Diff: src/bootstrapper.cc

Issue 1990183002: [serializer] do not cache resource data pointer for native source. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | src/factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698