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

Side by Side Diff: src/natives-external.cc

Issue 791723004: Reland "Use same blob format for internal and external snapshots." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 6 years 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
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/natives.h" 5 #include "src/natives.h"
6 6
7 #include "src/base/logging.h" 7 #include "src/base/logging.h"
8 #include "src/list.h" 8 #include "src/list.h"
9 #include "src/list-inl.h" 9 #include "src/list-inl.h"
10 #include "src/snapshot-source-sink.h" 10 #include "src/snapshot-source-sink.h"
11 #include "src/vector.h" 11 #include "src/vector.h"
12 12
13 #ifndef V8_USE_EXTERNAL_STARTUP_DATA
14 #error natives-external.cc is used only for the external snapshot build.
15 #endif // V8_USE_EXTERNAL_STARTUP_DATA
16
17
13 namespace v8 { 18 namespace v8 {
14 namespace internal { 19 namespace internal {
15 20
16 21
17 /** 22 /**
18 * NativesStore stores the 'native' (builtin) JS libraries. 23 * NativesStore stores the 'native' (builtin) JS libraries.
19 * 24 *
20 * NativesStore needs to be initialized before using V8, usually by the 25 * NativesStore needs to be initialized before using V8, usually by the
21 * embedder calling v8::SetNativesDataBlob, which calls SetNativesFromFile 26 * embedder calling v8::SetNativesDataBlob, which calls SetNativesFromFile
22 * below. 27 * below.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 140
136 /** 141 /**
137 * Read the Natives (library sources) blob, as generated by js2c + the build 142 * Read the Natives (library sources) blob, as generated by js2c + the build
138 * system. 143 * system.
139 */ 144 */
140 void SetNativesFromFile(StartupData* natives_blob) { 145 void SetNativesFromFile(StartupData* natives_blob) {
141 DCHECK(natives_blob); 146 DCHECK(natives_blob);
142 DCHECK(natives_blob->data); 147 DCHECK(natives_blob->data);
143 DCHECK(natives_blob->raw_size > 0); 148 DCHECK(natives_blob->raw_size > 0);
144 149
145 SnapshotByteSource bytes(reinterpret_cast<const byte*>(natives_blob->data), 150 SnapshotByteSource bytes(natives_blob->data, natives_blob->raw_size);
146 natives_blob->raw_size);
147 NativesHolder<CORE>::set(NativesStore::MakeFromScriptsSource(&bytes)); 151 NativesHolder<CORE>::set(NativesStore::MakeFromScriptsSource(&bytes));
148 NativesHolder<EXPERIMENTAL>::set(NativesStore::MakeFromScriptsSource(&bytes)); 152 NativesHolder<EXPERIMENTAL>::set(NativesStore::MakeFromScriptsSource(&bytes));
149 DCHECK(!bytes.HasMore()); 153 DCHECK(!bytes.HasMore());
150 } 154 }
151 155
152 156
153 // Implement NativesCollection<T> bsaed on NativesHolder + NativesStore. 157 // Implement NativesCollection<T> bsaed on NativesHolder + NativesStore.
154 // 158 //
155 // (The callers expect a purely static interface, since this is how the 159 // (The callers expect a purely static interface, since this is how the
156 // natives are usually compiled in. Since we implement them based on 160 // natives are usually compiled in. Since we implement them based on
(...skipping 24 matching lines...) Expand all
181 return NativesHolder<type>::get()->GetScriptName(index); 185 return NativesHolder<type>::get()->GetScriptName(index);
182 } 186 }
183 187
184 template <NativeType type> 188 template <NativeType type>
185 Vector<const char> NativesCollection<type>::GetScriptsSource() { 189 Vector<const char> NativesCollection<type>::GetScriptsSource() {
186 return NativesHolder<type>::get()->GetScriptsSource(); 190 return NativesHolder<type>::get()->GetScriptsSource();
187 } 191 }
188 192
189 193
190 // The compiler can't 'see' all uses of the static methods and hence 194 // The compiler can't 'see' all uses of the static methods and hence
191 // my chose to elide them. This we'll explicitly instantiate these. 195 // my choice to elide them. This we'll explicitly instantiate these.
192 template class NativesCollection<CORE>; 196 template class NativesCollection<CORE>;
193 template class NativesCollection<EXPERIMENTAL>; 197 template class NativesCollection<EXPERIMENTAL>;
194 198
195 } // namespace v8::internal 199 } // namespace v8::internal
196 } // namespace v8 200 } // namespace v8
OLDNEW
« no previous file with comments | « src/mksnapshot.cc ('k') | src/serialize.h » ('j') | src/snapshot-external.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698