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

Side by Side Diff: include/v8.h

Issue 844006: Merge changes up to V8 version 2.1.3 into the partial snapshots (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 years, 9 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 | « SConstruct ('k') | src/SConscript » ('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 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 template <class S> static inline Handle<T> Cast(Handle<S> that) { 255 template <class S> static inline Handle<T> Cast(Handle<S> that) {
256 #ifdef V8_ENABLE_CHECKS 256 #ifdef V8_ENABLE_CHECKS
257 // If we're going to perform the type check then we have to check 257 // If we're going to perform the type check then we have to check
258 // that the handle isn't empty before doing the checked cast. 258 // that the handle isn't empty before doing the checked cast.
259 if (that.IsEmpty()) return Handle<T>(); 259 if (that.IsEmpty()) return Handle<T>();
260 #endif 260 #endif
261 return Handle<T>(T::Cast(*that)); 261 return Handle<T>(T::Cast(*that));
262 } 262 }
263 263
264 template <class S> inline Handle<S> As() {
265 return Handle<S>::Cast(*this);
266 }
267
264 private: 268 private:
265 T* val_; 269 T* val_;
266 }; 270 };
267 271
268 272
269 /** 273 /**
270 * A light-weight stack-allocated object handle. All operations 274 * A light-weight stack-allocated object handle. All operations
271 * that return objects from within v8 return them in local handles. They 275 * that return objects from within v8 return them in local handles. They
272 * are created within HandleScopes, and all local handles allocated within a 276 * are created within HandleScopes, and all local handles allocated within a
273 * handle scope are destroyed when the handle scope is destroyed. Hence it 277 * handle scope are destroyed when the handle scope is destroyed. Hence it
(...skipping 14 matching lines...) Expand all
288 template <class S> inline Local(S* that) : Handle<T>(that) { } 292 template <class S> inline Local(S* that) : Handle<T>(that) { }
289 template <class S> static inline Local<T> Cast(Local<S> that) { 293 template <class S> static inline Local<T> Cast(Local<S> that) {
290 #ifdef V8_ENABLE_CHECKS 294 #ifdef V8_ENABLE_CHECKS
291 // If we're going to perform the type check then we have to check 295 // If we're going to perform the type check then we have to check
292 // that the handle isn't empty before doing the checked cast. 296 // that the handle isn't empty before doing the checked cast.
293 if (that.IsEmpty()) return Local<T>(); 297 if (that.IsEmpty()) return Local<T>();
294 #endif 298 #endif
295 return Local<T>(T::Cast(*that)); 299 return Local<T>(T::Cast(*that));
296 } 300 }
297 301
302 template <class S> inline Local<S> As() {
303 return Local<S>::Cast(*this);
304 }
305
298 /** Create a local handle for the content of another handle. 306 /** Create a local handle for the content of another handle.
299 * The referee is kept alive by the local handle even when 307 * The referee is kept alive by the local handle even when
300 * the original handle is destroyed/disposed. 308 * the original handle is destroyed/disposed.
301 */ 309 */
302 inline static Local<T> New(Handle<T> that); 310 inline static Local<T> New(Handle<T> that);
303 }; 311 };
304 312
305 313
306 /** 314 /**
307 * An object reference that is independent of any handle scope. Where 315 * An object reference that is independent of any handle scope. Where
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 369
362 template <class S> static inline Persistent<T> Cast(Persistent<S> that) { 370 template <class S> static inline Persistent<T> Cast(Persistent<S> that) {
363 #ifdef V8_ENABLE_CHECKS 371 #ifdef V8_ENABLE_CHECKS
364 // If we're going to perform the type check then we have to check 372 // If we're going to perform the type check then we have to check
365 // that the handle isn't empty before doing the checked cast. 373 // that the handle isn't empty before doing the checked cast.
366 if (that.IsEmpty()) return Persistent<T>(); 374 if (that.IsEmpty()) return Persistent<T>();
367 #endif 375 #endif
368 return Persistent<T>(T::Cast(*that)); 376 return Persistent<T>(T::Cast(*that));
369 } 377 }
370 378
379 template <class S> inline Persistent<S> As() {
380 return Persistent<S>::Cast(*this);
381 }
382
371 /** 383 /**
372 * Creates a new persistent handle for an existing local or 384 * Creates a new persistent handle for an existing local or
373 * persistent handle. 385 * persistent handle.
374 */ 386 */
375 inline static Persistent<T> New(Handle<T> that); 387 inline static Persistent<T> New(Handle<T> that);
376 388
377 /** 389 /**
378 * Releases the storage cell referenced by this persistent handle. 390 * Releases the storage cell referenced by this persistent handle.
379 * Does not remove the reference to the cell from any handles. 391 * Does not remove the reference to the cell from any handles.
380 * This handle's reference, and any any other references to the storage 392 * This handle's reference, and any any other references to the storage
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 /** 543 /**
532 * A compiled JavaScript script. 544 * A compiled JavaScript script.
533 */ 545 */
534 class V8EXPORT Script { 546 class V8EXPORT Script {
535 public: 547 public:
536 548
537 /** 549 /**
538 * Compiles the specified script (context-independent). 550 * Compiles the specified script (context-independent).
539 * 551 *
540 * \param source Script source code. 552 * \param source Script source code.
541 * \param origin Script origin, owned by caller, no references are kept 553 * \param origin Script origin, owned by caller, no references are kept
542 * when New() returns 554 * when New() returns
543 * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() 555 * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile()
544 * using pre_data speeds compilation if it's done multiple times. 556 * using pre_data speeds compilation if it's done multiple times.
545 * Owned by caller, no references are kept when New() returns. 557 * Owned by caller, no references are kept when New() returns.
546 * \param script_data Arbitrary data associated with script. Using 558 * \param script_data Arbitrary data associated with script. Using
547 * this has same effect as calling SetData(), but allows data to be 559 * this has same effect as calling SetData(), but allows data to be
548 * available to compile event handlers. 560 * available to compile event handlers.
549 * \return Compiled script object (context independent; when run it 561 * \return Compiled script object (context independent; when run it
550 * will use the currently entered context). 562 * will use the currently entered context).
551 */ 563 */
552 static Local<Script> New(Handle<String> source, 564 static Local<Script> New(Handle<String> source,
553 ScriptOrigin* origin = NULL, 565 ScriptOrigin* origin = NULL,
554 ScriptData* pre_data = NULL, 566 ScriptData* pre_data = NULL,
555 Handle<String> script_data = Handle<String>()); 567 Handle<String> script_data = Handle<String>());
556 568
557 /** 569 /**
558 * Compiles the specified script using the specified file name 570 * Compiles the specified script using the specified file name
559 * object (typically a string) as the script's origin. 571 * object (typically a string) as the script's origin.
560 * 572 *
561 * \param source Script source code. 573 * \param source Script source code.
562 * \patam file_name file name object (typically a string) to be used 574 * \param file_name file name object (typically a string) to be used
563 * as the script's origin. 575 * as the script's origin.
564 * \return Compiled script object (context independent; when run it 576 * \return Compiled script object (context independent; when run it
565 * will use the currently entered context). 577 * will use the currently entered context).
566 */ 578 */
567 static Local<Script> New(Handle<String> source, 579 static Local<Script> New(Handle<String> source,
568 Handle<Value> file_name); 580 Handle<Value> file_name);
569 581
570 /** 582 /**
571 * Compiles the specified script (bound to current context). 583 * Compiles the specified script (bound to current context).
572 * 584 *
573 * \param source Script source code. 585 * \param source Script source code.
574 * \param origin Script origin, owned by caller, no references are kept 586 * \param origin Script origin, owned by caller, no references are kept
575 * when Compile() returns 587 * when Compile() returns
576 * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() 588 * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile()
577 * using pre_data speeds compilation if it's done multiple times. 589 * using pre_data speeds compilation if it's done multiple times.
578 * Owned by caller, no references are kept when Compile() returns. 590 * Owned by caller, no references are kept when Compile() returns.
579 * \param script_data Arbitrary data associated with script. Using 591 * \param script_data Arbitrary data associated with script. Using
580 * this has same effect as calling SetData(), but makes data available 592 * this has same effect as calling SetData(), but makes data available
581 * earlier (i.e. to compile event handlers). 593 * earlier (i.e. to compile event handlers).
582 * \return Compiled script object, bound to the context that was active 594 * \return Compiled script object, bound to the context that was active
583 * when this function was called. When run it will always use this 595 * when this function was called. When run it will always use this
584 * context. 596 * context.
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 * Returns true if this value is external. 760 * Returns true if this value is external.
749 */ 761 */
750 bool IsExternal() const; 762 bool IsExternal() const;
751 763
752 /** 764 /**
753 * Returns true if this value is a 32-bit signed integer. 765 * Returns true if this value is a 32-bit signed integer.
754 */ 766 */
755 bool IsInt32() const; 767 bool IsInt32() const;
756 768
757 /** 769 /**
770 * Returns true if this value is a 32-bit signed integer.
771 */
772 bool IsUint32() const;
773
774 /**
758 * Returns true if this value is a Date. 775 * Returns true if this value is a Date.
759 */ 776 */
760 bool IsDate() const; 777 bool IsDate() const;
761 778
762 Local<Boolean> ToBoolean() const; 779 Local<Boolean> ToBoolean() const;
763 Local<Number> ToNumber() const; 780 Local<Number> ToNumber() const;
764 Local<String> ToString() const; 781 Local<String> ToString() const;
765 Local<String> ToDetailString() const; 782 Local<String> ToDetailString() const;
766 Local<Object> ToObject() const; 783 Local<Object> ToObject() const;
767 Local<Integer> ToInteger() const; 784 Local<Integer> ToInteger() const;
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 1188
1172 /** 1189 /**
1173 * A JavaScript object (ECMA-262, 4.3.3) 1190 * A JavaScript object (ECMA-262, 4.3.3)
1174 */ 1191 */
1175 class V8EXPORT Object : public Value { 1192 class V8EXPORT Object : public Value {
1176 public: 1193 public:
1177 bool Set(Handle<Value> key, 1194 bool Set(Handle<Value> key,
1178 Handle<Value> value, 1195 Handle<Value> value,
1179 PropertyAttribute attribs = None); 1196 PropertyAttribute attribs = None);
1180 1197
1198 bool Set(uint32_t index,
1199 Handle<Value> value);
1200
1181 // Sets a local property on this object bypassing interceptors and 1201 // Sets a local property on this object bypassing interceptors and
1182 // overriding accessors or read-only properties. 1202 // overriding accessors or read-only properties.
1183 // 1203 //
1184 // Note that if the object has an interceptor the property will be set 1204 // Note that if the object has an interceptor the property will be set
1185 // locally, but since the interceptor takes precedence the local property 1205 // locally, but since the interceptor takes precedence the local property
1186 // will only be returned if the interceptor doesn't return a value. 1206 // will only be returned if the interceptor doesn't return a value.
1187 // 1207 //
1188 // Note also that this only works for named properties. 1208 // Note also that this only works for named properties.
1189 bool ForceSet(Handle<Value> key, 1209 bool ForceSet(Handle<Value> key,
1190 Handle<Value> value, 1210 Handle<Value> value,
1191 PropertyAttribute attribs = None); 1211 PropertyAttribute attribs = None);
1192 1212
1193 Local<Value> Get(Handle<Value> key); 1213 Local<Value> Get(Handle<Value> key);
1194 1214
1215 Local<Value> Get(uint32_t index);
1216
1195 // TODO(1245389): Replace the type-specific versions of these 1217 // TODO(1245389): Replace the type-specific versions of these
1196 // functions with generic ones that accept a Handle<Value> key. 1218 // functions with generic ones that accept a Handle<Value> key.
1197 bool Has(Handle<String> key); 1219 bool Has(Handle<String> key);
1198 1220
1199 bool Delete(Handle<String> key); 1221 bool Delete(Handle<String> key);
1200 1222
1201 // Delete a property on this object bypassing interceptors and 1223 // Delete a property on this object bypassing interceptors and
1202 // ignoring dont-delete attributes. 1224 // ignoring dont-delete attributes.
1203 bool ForceDelete(Handle<Value> key); 1225 bool ForceDelete(Handle<Value> key);
1204 1226
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2435 2457
2436 /** 2458 /**
2437 * Forcefully terminate the current thread of JavaScript execution. 2459 * Forcefully terminate the current thread of JavaScript execution.
2438 * 2460 *
2439 * This method can be used by any thread even if that thread has not 2461 * This method can be used by any thread even if that thread has not
2440 * acquired the V8 lock with a Locker object. 2462 * acquired the V8 lock with a Locker object.
2441 */ 2463 */
2442 static void TerminateExecution(); 2464 static void TerminateExecution();
2443 2465
2444 /** 2466 /**
2467 * Is V8 terminating JavaScript execution.
2468 *
2469 * Returns true if JavaScript execution is currently terminating
2470 * because of a call to TerminateExecution. In that case there are
2471 * still JavaScript frames on the stack and the termination
2472 * exception is still active.
2473 */
2474 static bool IsExecutionTerminating();
2475
2476 /**
2445 * Releases any resources used by v8 and stops any utility threads 2477 * Releases any resources used by v8 and stops any utility threads
2446 * that may be running. Note that disposing v8 is permanent, it 2478 * that may be running. Note that disposing v8 is permanent, it
2447 * cannot be reinitialized. 2479 * cannot be reinitialized.
2448 * 2480 *
2449 * It should generally not be necessary to dispose v8 before exiting 2481 * It should generally not be necessary to dispose v8 before exiting
2450 * a process, this should happen automatically. It is only necessary 2482 * a process, this should happen automatically. It is only necessary
2451 * to use if the process needs the resources taken up by v8. 2483 * to use if the process needs the resources taken up by v8.
2452 */ 2484 */
2453 static bool Dispose(); 2485 static bool Dispose();
2454 2486
(...skipping 11 matching lines...) Expand all
2466 * as much cleanup as it will be able to do. 2498 * as much cleanup as it will be able to do.
2467 */ 2499 */
2468 static bool IdleNotification(); 2500 static bool IdleNotification();
2469 2501
2470 /** 2502 /**
2471 * Optional notification that the system is running low on memory. 2503 * Optional notification that the system is running low on memory.
2472 * V8 uses these notifications to attempt to free memory. 2504 * V8 uses these notifications to attempt to free memory.
2473 */ 2505 */
2474 static void LowMemoryNotification(); 2506 static void LowMemoryNotification();
2475 2507
2508 /**
2509 * Optional notification that a context has been disposed. V8 uses
2510 * these notifications to guide the GC heuristic. Returns the number
2511 * of context disposals - including this one - since the last time
2512 * V8 had a chance to clean up.
2513 */
2514 static int ContextDisposedNotification();
2515
2476 private: 2516 private:
2477 V8(); 2517 V8();
2478 2518
2479 static internal::Object** GlobalizeReference(internal::Object** handle); 2519 static internal::Object** GlobalizeReference(internal::Object** handle);
2480 static void DisposeGlobal(internal::Object** global_handle); 2520 static void DisposeGlobal(internal::Object** global_handle);
2481 static void MakeWeak(internal::Object** global_handle, 2521 static void MakeWeak(internal::Object** global_handle,
2482 void* data, 2522 void* data,
2483 WeakReferenceCallback); 2523 WeakReferenceCallback);
2484 static void ClearWeak(internal::Object** global_handle); 2524 static void ClearWeak(internal::Object** global_handle);
2485 static bool IsGlobalNearDeath(internal::Object** global_handle); 2525 static bool IsGlobalNearDeath(internal::Object** global_handle);
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 3315
3276 } // namespace v8 3316 } // namespace v8
3277 3317
3278 3318
3279 #undef V8EXPORT 3319 #undef V8EXPORT
3280 #undef V8EXPORT_INLINE 3320 #undef V8EXPORT_INLINE
3281 #undef TYPE_CHECK 3321 #undef TYPE_CHECK
3282 3322
3283 3323
3284 #endif // V8_H_ 3324 #endif // V8_H_
OLDNEW
« no previous file with comments | « SConstruct ('k') | src/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698