OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "src/base/utils/random-number-generator.h" | 21 #include "src/base/utils/random-number-generator.h" |
22 #include "src/bootstrapper.h" | 22 #include "src/bootstrapper.h" |
23 #include "src/code-stubs.h" | 23 #include "src/code-stubs.h" |
24 #include "src/compiler.h" | 24 #include "src/compiler.h" |
25 #include "src/conversions-inl.h" | 25 #include "src/conversions-inl.h" |
26 #include "src/counters.h" | 26 #include "src/counters.h" |
27 #include "src/cpu-profiler.h" | 27 #include "src/cpu-profiler.h" |
28 #include "src/debug.h" | 28 #include "src/debug.h" |
29 #include "src/deoptimizer.h" | 29 #include "src/deoptimizer.h" |
30 #include "src/execution.h" | 30 #include "src/execution.h" |
31 #include "src/full-codegen.h" | |
32 #include "src/global-handles.h" | 31 #include "src/global-handles.h" |
33 #include "src/heap-profiler.h" | 32 #include "src/heap-profiler.h" |
34 #include "src/heap-snapshot-generator-inl.h" | 33 #include "src/heap-snapshot-generator-inl.h" |
35 #include "src/icu_util.h" | 34 #include "src/icu_util.h" |
36 #include "src/json-parser.h" | 35 #include "src/json-parser.h" |
37 #include "src/messages.h" | 36 #include "src/messages.h" |
38 #include "src/natives.h" | 37 #include "src/natives.h" |
39 #include "src/parser.h" | 38 #include "src/parser.h" |
40 #include "src/profile-generator-inl.h" | 39 #include "src/profile-generator-inl.h" |
41 #include "src/property.h" | 40 #include "src/property.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 if (try_catch.HasCaught()) return false; | 214 if (try_catch.HasCaught()) return false; |
216 ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>")); | 215 ScriptOrigin origin(String::NewFromUtf8(isolate, "<embedded script>")); |
217 ScriptCompiler::Source source(source_string, origin); | 216 ScriptCompiler::Source source(source_string, origin); |
218 Local<Script> script = ScriptCompiler::Compile(isolate, &source); | 217 Local<Script> script = ScriptCompiler::Compile(isolate, &source); |
219 if (try_catch.HasCaught()) return false; | 218 if (try_catch.HasCaught()) return false; |
220 script->Run(); | 219 script->Run(); |
221 return !try_catch.HasCaught(); | 220 return !try_catch.HasCaught(); |
222 } | 221 } |
223 | 222 |
224 | 223 |
225 void CheckDefaultReservationSizes(const i::StartupSerializer& startup_ser, | |
226 const i::PartialSerializer& context_ser) { | |
227 #ifdef DEBUG | |
228 i::List<i::SerializedData::Reservation> startup_reservations; | |
229 i::List<i::SerializedData::Reservation> context_reservations; | |
230 startup_ser.EncodeReservations(&startup_reservations); | |
231 context_ser.EncodeReservations(&context_reservations); | |
232 for (int space = 0; space < i::Serializer::kNumberOfSpaces; space++) { | |
233 // Exactly one chunk per space. | |
234 CHECK(startup_reservations[space].is_last()); | |
235 CHECK(startup_reservations[space].is_last()); | |
236 uint32_t sum = startup_reservations[space].chunk_size() + | |
237 context_reservations[space].chunk_size(); | |
238 uint32_t limit = 0; | |
239 const int constant_pool_delta = i::FLAG_enable_ool_constant_pool ? 48 : 0; | |
240 switch (space) { | |
241 case i::NEW_SPACE: | |
242 limit = 3 * i::kPointerSize; | |
243 break; | |
244 case i::OLD_POINTER_SPACE: | |
245 limit = (128 + constant_pool_delta) * i::kPointerSize * i::KB; | |
246 break; | |
247 case i::OLD_DATA_SPACE: | |
248 limit = 192 * i::KB; | |
249 break; | |
250 case i::MAP_SPACE: | |
251 limit = 16 * i::kPointerSize * i::KB; | |
252 break; | |
253 case i::CELL_SPACE: | |
254 limit = 16 * i::kPointerSize * i::KB; | |
255 break; | |
256 case i::PROPERTY_CELL_SPACE: | |
257 limit = 8 * i::kPointerSize * i::KB; | |
258 break; | |
259 case i::CODE_SPACE: | |
260 limit = RoundUp((480 - constant_pool_delta) * i::KB * | |
261 i::FullCodeGenerator::kBootCodeSizeMultiplier / 100, | |
262 i::kPointerSize); | |
263 break; | |
264 default: | |
265 break; | |
266 } | |
267 CHECK_LE(sum, limit); | |
268 } | |
269 #endif // DEBUG | |
270 } | |
271 | |
272 | |
273 StartupData V8::CreateSnapshotDataBlob(char* custom_source) { | 224 StartupData V8::CreateSnapshotDataBlob(char* custom_source) { |
274 Isolate::CreateParams params; | 225 Isolate::CreateParams params; |
275 params.enable_serializer = true; | 226 params.enable_serializer = true; |
276 Isolate* isolate = v8::Isolate::New(params); | 227 Isolate* isolate = v8::Isolate::New(params); |
277 StartupData result = {NULL, 0}; | 228 StartupData result = {NULL, 0}; |
278 { | 229 { |
279 Isolate::Scope isolate_scope(isolate); | 230 Isolate::Scope isolate_scope(isolate); |
280 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); | 231 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); |
281 Persistent<Context> context; | 232 Persistent<Context> context; |
282 i::Snapshot::Metadata metadata; | 233 i::Snapshot::Metadata metadata; |
(...skipping 23 matching lines...) Expand all Loading... |
306 | 257 |
307 i::SnapshotByteSink snapshot_sink; | 258 i::SnapshotByteSink snapshot_sink; |
308 i::StartupSerializer ser(internal_isolate, &snapshot_sink); | 259 i::StartupSerializer ser(internal_isolate, &snapshot_sink); |
309 ser.SerializeStrongReferences(); | 260 ser.SerializeStrongReferences(); |
310 | 261 |
311 i::SnapshotByteSink context_sink; | 262 i::SnapshotByteSink context_sink; |
312 i::PartialSerializer context_ser(internal_isolate, &ser, &context_sink); | 263 i::PartialSerializer context_ser(internal_isolate, &ser, &context_sink); |
313 context_ser.Serialize(&raw_context); | 264 context_ser.Serialize(&raw_context); |
314 ser.SerializeWeakReferences(); | 265 ser.SerializeWeakReferences(); |
315 | 266 |
316 i::SnapshotData sd(snapshot_sink, ser); | 267 result = i::Snapshot::CreateSnapshotBlob(ser, context_ser, metadata); |
317 i::SnapshotData csd(context_sink, context_ser); | |
318 | |
319 if (custom_source == NULL) CheckDefaultReservationSizes(ser, context_ser); | |
320 | |
321 result = i::Snapshot::CreateSnapshotBlob(sd.RawData(), csd.RawData(), | |
322 metadata); | |
323 } | 268 } |
324 } | 269 } |
325 isolate->Dispose(); | 270 isolate->Dispose(); |
326 return result; | 271 return result; |
327 } | 272 } |
328 | 273 |
329 | 274 |
330 void V8::SetFlagsFromString(const char* str, int length) { | 275 void V8::SetFlagsFromString(const char* str, int length) { |
331 i::FlagList::SetFlagsFromString(str, length); | 276 i::FlagList::SetFlagsFromString(str, length); |
332 } | 277 } |
(...skipping 7504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7837 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7782 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7838 Address callback_address = | 7783 Address callback_address = |
7839 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7784 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7840 VMState<EXTERNAL> state(isolate); | 7785 VMState<EXTERNAL> state(isolate); |
7841 ExternalCallbackScope call_scope(isolate, callback_address); | 7786 ExternalCallbackScope call_scope(isolate, callback_address); |
7842 callback(info); | 7787 callback(info); |
7843 } | 7788 } |
7844 | 7789 |
7845 | 7790 |
7846 } } // namespace v8::internal | 7791 } } // namespace v8::internal |
OLD | NEW |