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

Side by Side Diff: include/v8.h

Issue 2566002: [Isolates] Isolate API: first draft. (Closed)
Patch Set: Review fixes Created 10 years, 6 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 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 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2378 void set_used_heap_size(size_t size) { used_heap_size_ = size; } 2378 void set_used_heap_size(size_t size) { used_heap_size_ = size; }
2379 2379
2380 size_t total_heap_size_; 2380 size_t total_heap_size_;
2381 size_t used_heap_size_; 2381 size_t used_heap_size_;
2382 2382
2383 friend class V8; 2383 friend class V8;
2384 }; 2384 };
2385 2385
2386 2386
2387 /** 2387 /**
2388 * Isolate represents an isolated instace of the V8 engine. V8
Maxim.Mossienko 2010/07/01 08:31:50 typo: instace -> instance
Vitaly Repeshko 2010/07/01 22:00:57 Fixed.
2389 * isolates have completely separate states. Objects from one isolate
2390 * must not be used in other isolates. When V8 is initialized a
2391 * default isolate is implicitly created and entered. The embedder
2392 * can create additional isolates and use them in parallel in multiple
2393 * threads. An isolate can be entered by at most one thread at any
2394 * given time. The Locker/Unlocker API can be used to synchronize.
Maxim.Mossienko 2010/07/01 09:17:02 This is not currently possible in this API draft.
2395 */
2396 class V8EXPORT Isolate {
2397 public:
Maxim.Mossienko 2010/07/01 08:31:50 I think that if we are to preserve API compatibili
2398 /**
2399 * Stack-allocated class which sets the isolate for all operations
2400 * executed within a local scope.
2401 */
2402 class V8EXPORT Scope {
2403 public:
2404 explicit Scope(Isolate* isolate) : isolate_(isolate) {
2405 isolate->Enter();
2406 }
2407
2408 ~Scope() { isolate_->Exit(); }
2409
2410 private:
2411 Isolate* const isolate_;
2412
2413 Scope(const Scope&);
2414 Scope& operator=(const Scope&);
2415 };
2416
2417 /**
2418 * Creates a new isolate. Does not change the currently entered
2419 * isolate.
2420 *
2421 * When an isolate is no longer used its resources should be freed
2422 * by calling Dispose(). Using the delete operator is not allowed.
2423 */
2424 static Isolate* New();
2425
2426 /**
2427 * Returns the entered isolate for the current thread or NULL in
2428 * case there is no current isolate.
2429 */
2430 static Isolate* GetCurrent();
2431
2432 /**
2433 * Methods below this point require holding a lock in a
Maxim.Mossienko 2010/07/01 08:31:50 IMO bare 'lock' word is confusing in the descripti
Vitaly Repeshko 2010/07/01 22:00:57 Clarified how the embedder is supposed to hold a l
2434 * multi-threaded environment.
2435 */
2436
2437 /**
2438 * Sets this isolate as the entered one for the current thread.
2439 * Saves the previously entered one (if any), so that it can be
2440 * restored when exiting. Re-entering an isolate is allowed.
2441 */
2442 void Enter();
2443
2444 /**
2445 * Exits this isolate by restoring the previously entered one in the
2446 * current thread. The isolate may still stay the same, if it was
2447 * entered more than once.
2448 *
2449 * Requires: this == Isolate::GetCurrent().
2450 */
2451 void Exit();
2452
2453 /**
2454 * Disposes the isolate. The isolate must not be entered by any
2455 * thread to be disposable.
2456 */
2457 void Dispose();
2458
2459 private:
2460
2461 Isolate();
Maxim.Mossienko 2010/07/01 09:17:02 Following Locker statics go here: /** * Return
2462 Isolate(const Isolate&);
2463 ~Isolate();
2464 Isolate& operator=(const Isolate&);
2465 void* operator new(size_t size);
2466 void operator delete(void*, size_t);
2467 };
2468
2469
2470 /**
2388 * Container class for static utility functions. 2471 * Container class for static utility functions.
2389 */ 2472 */
2390 class V8EXPORT V8 { 2473 class V8EXPORT V8 {
2391 public: 2474 public:
2392 /** Set the callback to invoke in case of fatal errors. */ 2475 /** Set the callback to invoke in case of fatal errors. */
2393 static void SetFatalErrorHandler(FatalErrorCallback that); 2476 static void SetFatalErrorHandler(FatalErrorCallback that);
2394 2477
2395 /** 2478 /**
2396 * Ignore out-of-memory exceptions. 2479 * Ignore out-of-memory exceptions.
2397 * 2480 *
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3548 3631
3549 } // namespace v8 3632 } // namespace v8
3550 3633
3551 3634
3552 #undef V8EXPORT 3635 #undef V8EXPORT
3553 #undef V8EXPORT_INLINE 3636 #undef V8EXPORT_INLINE
3554 #undef TYPE_CHECK 3637 #undef TYPE_CHECK
3555 3638
3556 3639
3557 #endif // V8_H_ 3640 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698