| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 { | 182 { |
| 183 if (!status) { | 183 if (!status) { |
| 184 TRACE_EVENT_BEGIN0("v8", name); | 184 TRACE_EVENT_BEGIN0("v8", name); |
| 185 } else { | 185 } else { |
| 186 TRACE_EVENT_END0("v8", name); | 186 TRACE_EVENT_END0("v8", name); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 static void initializeV8Common(v8::Isolate* isolate) | 190 static void initializeV8Common(v8::Isolate* isolate) |
| 191 { | 191 { |
| 192 v8::ResourceConstraints constraints; | |
| 193 constraints.ConfigureDefaults(static_cast<uint64_t>(blink::Platform::current
()->physicalMemoryMB()) << 20, static_cast<uint32_t>(blink::Platform::current()-
>virtualMemoryLimitMB()) << 20, static_cast<uint32_t>(blink::Platform::current()
->numberOfProcessors())); | |
| 194 v8::SetResourceConstraints(isolate, &constraints); | |
| 195 | |
| 196 v8::V8::AddGCPrologueCallback(V8GCController::gcPrologue); | 192 v8::V8::AddGCPrologueCallback(V8GCController::gcPrologue); |
| 197 v8::V8::AddGCEpilogueCallback(V8GCController::gcEpilogue); | 193 v8::V8::AddGCEpilogueCallback(V8GCController::gcEpilogue); |
| 198 | 194 |
| 199 v8::Debug::SetLiveEditEnabled(isolate, false); | 195 v8::Debug::SetLiveEditEnabled(isolate, false); |
| 200 | 196 |
| 201 isolate->SetAutorunMicrotasks(false); | 197 isolate->SetAutorunMicrotasks(false); |
| 202 } | 198 } |
| 203 | 199 |
| 204 void V8Initializer::initializeMainThreadIfNeeded(v8::Isolate* isolate) | 200 void V8Initializer::initializeMainThreadIfNeeded() |
| 205 { | 201 { |
| 206 ASSERT(isMainThread()); | 202 ASSERT(isMainThread()); |
| 207 | 203 |
| 208 static bool initialized = false; | 204 static bool initialized = false; |
| 209 if (initialized) | 205 if (initialized) |
| 210 return; | 206 return; |
| 211 initialized = true; | 207 initialized = true; |
| 212 | 208 |
| 209 gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, v8ArrayBu
fferAllocator()); |
| 210 |
| 211 v8::Isolate* isolate = V8PerIsolateData::initialize(); |
| 212 |
| 213 initializeV8Common(isolate); | 213 initializeV8Common(isolate); |
| 214 | 214 |
| 215 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); | 215 v8::V8::SetFatalErrorHandler(reportFatalErrorInMainThread); |
| 216 V8PerIsolateData::ensureInitialized(isolate); | |
| 217 v8::V8::AddMessageListener(messageHandlerInMainThread); | 216 v8::V8::AddMessageListener(messageHandlerInMainThread); |
| 218 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain
Thread); | 217 v8::V8::SetFailedAccessCheckCallbackFunction(failedAccessCheckCallbackInMain
Thread); |
| 219 v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbac
kInMainThread); | 218 v8::V8::SetAllowCodeGenerationFromStringsCallback(codeGenerationCheckCallbac
kInMainThread); |
| 220 | 219 |
| 221 isolate->SetEventLogger(timerTraceProfilerInMainThread); | 220 isolate->SetEventLogger(timerTraceProfilerInMainThread); |
| 222 | 221 |
| 223 ScriptProfiler::initialize(); | 222 ScriptProfiler::initialize(); |
| 224 } | 223 } |
| 225 | 224 |
| 226 static void reportFatalErrorInWorker(const char* location, const char* message) | 225 static void reportFatalErrorInWorker(const char* location, const char* message) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 v8::V8::AddMessageListener(messageHandlerInWorker); | 268 v8::V8::AddMessageListener(messageHandlerInWorker); |
| 270 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); | 269 v8::V8::SetFatalErrorHandler(reportFatalErrorInWorker); |
| 271 | 270 |
| 272 v8::ResourceConstraints resourceConstraints; | 271 v8::ResourceConstraints resourceConstraints; |
| 273 uint32_t here; | 272 uint32_t here; |
| 274 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); | 273 resourceConstraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uin
t32_t*)); |
| 275 v8::SetResourceConstraints(isolate, &resourceConstraints); | 274 v8::SetResourceConstraints(isolate, &resourceConstraints); |
| 276 } | 275 } |
| 277 | 276 |
| 278 } // namespace blink | 277 } // namespace blink |
| OLD | NEW |