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

Side by Side Diff: src/api.cc

Issue 238773003: Removed EnterIsolateIfNeeded and a soon-to-be-useless assertion. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/isolate.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate, 238 static inline bool EnsureInitializedForIsolate(i::Isolate* isolate,
239 const char* location) { 239 const char* location) {
240 return (isolate != NULL && isolate->IsInitialized()) || 240 return (isolate != NULL && isolate->IsInitialized()) ||
241 Utils::ApiCheck(InitializeHelper(isolate), 241 Utils::ApiCheck(InitializeHelper(isolate),
242 location, 242 location,
243 "Error initializing V8"); 243 "Error initializing V8");
244 } 244 }
245 245
246 246
247 // Some initializing API functions are called early and may be
248 // called on a thread different from static initializer thread.
249 // If Isolate API is used, Isolate::Enter() will initialize TLS so
250 // Isolate::Current() works. If it's a legacy case, then the thread
251 // may not have TLS initialized yet. However, in initializing APIs it
252 // may be too early to call EnsureInitialized() - some pre-init
253 // parameters still have to be configured.
254 static inline i::Isolate* EnterIsolateIfNeeded() {
255 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
256 if (isolate != NULL)
257 return isolate;
258
259 i::Isolate::EnterDefaultIsolate();
260 isolate = i::Isolate::Current();
261 return isolate;
262 }
263
264
265 StartupDataDecompressor::StartupDataDecompressor() 247 StartupDataDecompressor::StartupDataDecompressor()
266 : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) { 248 : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) {
267 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) { 249 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
268 raw_data[i] = NULL; 250 raw_data[i] = NULL;
269 } 251 }
270 } 252 }
271 253
272 254
273 StartupDataDecompressor::~StartupDataDecompressor() { 255 StartupDataDecompressor::~StartupDataDecompressor() {
274 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) { 256 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 decompressed_data[kExperimentalLibraries].raw_size); 366 decompressed_data[kExperimentalLibraries].raw_size);
385 i::Vector<const char> exp_libraries_source( 367 i::Vector<const char> exp_libraries_source(
386 decompressed_data[kExperimentalLibraries].data, 368 decompressed_data[kExperimentalLibraries].data,
387 decompressed_data[kExperimentalLibraries].raw_size); 369 decompressed_data[kExperimentalLibraries].raw_size);
388 i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source); 370 i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source);
389 #endif 371 #endif
390 } 372 }
391 373
392 374
393 void V8::SetFatalErrorHandler(FatalErrorCallback that) { 375 void V8::SetFatalErrorHandler(FatalErrorCallback that) {
394 i::Isolate* isolate = EnterIsolateIfNeeded(); 376 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
395 isolate->set_exception_behavior(that); 377 isolate->set_exception_behavior(that);
396 } 378 }
397 379
398 380
399 void V8::SetAllowCodeGenerationFromStringsCallback( 381 void V8::SetAllowCodeGenerationFromStringsCallback(
400 AllowCodeGenerationFromStringsCallback callback) { 382 AllowCodeGenerationFromStringsCallback callback) {
401 i::Isolate* isolate = EnterIsolateIfNeeded(); 383 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
402 isolate->set_allow_code_gen_callback(callback); 384 isolate->set_allow_code_gen_callback(callback);
403 } 385 }
404 386
405 387
406 void V8::SetFlagsFromString(const char* str, int length) { 388 void V8::SetFlagsFromString(const char* str, int length) {
407 i::FlagList::SetFlagsFromString(str, length); 389 i::FlagList::SetFlagsFromString(str, length);
408 } 390 }
409 391
410 392
411 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { 393 void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) {
(...skipping 5889 matching lines...) Expand 10 before | Expand all | Expand 10 after
6301 int frame_limit, 6283 int frame_limit,
6302 StackTrace::StackTraceOptions options) { 6284 StackTrace::StackTraceOptions options) {
6303 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions( 6285 i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions(
6304 capture, 6286 capture,
6305 frame_limit, 6287 frame_limit,
6306 options); 6288 options);
6307 } 6289 }
6308 6290
6309 6291
6310 void V8::SetCounterFunction(CounterLookupCallback callback) { 6292 void V8::SetCounterFunction(CounterLookupCallback callback) {
6311 i::Isolate* isolate = EnterIsolateIfNeeded(); 6293 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
6312 isolate->stats_table()->SetCounterFunction(callback); 6294 isolate->stats_table()->SetCounterFunction(callback);
6313 } 6295 }
6314 6296
6315 6297
6316 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) { 6298 void V8::SetCreateHistogramFunction(CreateHistogramCallback callback) {
6317 i::Isolate* isolate = EnterIsolateIfNeeded(); 6299 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
6318 isolate->stats_table()->SetCreateHistogramFunction(callback); 6300 isolate->stats_table()->SetCreateHistogramFunction(callback);
6319 isolate->InitializeLoggingAndCounters(); 6301 isolate->InitializeLoggingAndCounters();
6320 isolate->counters()->ResetHistograms(); 6302 isolate->counters()->ResetHistograms();
6321 } 6303 }
6322 6304
6323 6305
6324 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) { 6306 void V8::SetAddHistogramSampleFunction(AddHistogramSampleCallback callback) {
6325 i::Isolate* isolate = EnterIsolateIfNeeded(); 6307 i::Isolate* isolate = i::Isolate::UncheckedCurrent();
6326 isolate->stats_table()-> 6308 isolate->stats_table()->
6327 SetAddHistogramSampleFunction(callback); 6309 SetAddHistogramSampleFunction(callback);
6328 } 6310 }
6329 6311
6330 void V8::SetFailedAccessCheckCallbackFunction( 6312 void V8::SetFailedAccessCheckCallbackFunction(
6331 FailedAccessCheckCallback callback) { 6313 FailedAccessCheckCallback callback) {
6332 i::Isolate* isolate = i::Isolate::Current(); 6314 i::Isolate* isolate = i::Isolate::Current();
6333 isolate->SetFailedAccessCheckCallback(callback); 6315 isolate->SetFailedAccessCheckCallback(callback);
6334 } 6316 }
6335 6317
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
7626 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7608 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7627 Address callback_address = 7609 Address callback_address =
7628 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7610 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7629 VMState<EXTERNAL> state(isolate); 7611 VMState<EXTERNAL> state(isolate);
7630 ExternalCallbackScope call_scope(isolate, callback_address); 7612 ExternalCallbackScope call_scope(isolate, callback_address);
7631 callback(info); 7613 callback(info);
7632 } 7614 }
7633 7615
7634 7616
7635 } } // namespace v8::internal 7617 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698