| OLD | NEW |
| 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 Uncompilable<Object>(); | 473 Uncompilable<Object>(); |
| 474 } | 474 } |
| 475 // TODO(dcarney): come up with a good compile error here. | 475 // TODO(dcarney): come up with a good compile error here. |
| 476 template<class O> V8_INLINE static void Uncompilable() { | 476 template<class O> V8_INLINE static void Uncompilable() { |
| 477 TYPE_CHECK(O, Primitive); | 477 TYPE_CHECK(O, Primitive); |
| 478 } | 478 } |
| 479 }; | 479 }; |
| 480 | 480 |
| 481 | 481 |
| 482 /** | 482 /** |
| 483 * Helper class traits to allow copying and assignment of Persistent. |
| 484 * This will clone the contents of storage cell, but not any of the flags, etc. |
| 485 */ |
| 486 template<class T> |
| 487 struct CopyablePersistentTraits { |
| 488 typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent; |
| 489 static const bool kResetInDestructor = true; |
| 490 template<class S, class M> |
| 491 static V8_INLINE void Copy(const Persistent<S, M>& source, |
| 492 CopyablePersistent* dest) { |
| 493 // do nothing, just allow copy |
| 494 } |
| 495 }; |
| 496 |
| 497 |
| 498 /** |
| 483 * An object reference that is independent of any handle scope. Where | 499 * An object reference that is independent of any handle scope. Where |
| 484 * a Local handle only lives as long as the HandleScope in which it was | 500 * a Local handle only lives as long as the HandleScope in which it was |
| 485 * allocated, a Persistent handle remains valid until it is explicitly | 501 * allocated, a Persistent handle remains valid until it is explicitly |
| 486 * disposed. | 502 * disposed. |
| 487 * | 503 * |
| 488 * A persistent handle contains a reference to a storage cell within | 504 * A persistent handle contains a reference to a storage cell within |
| 489 * the v8 engine which holds an object value and which is updated by | 505 * the v8 engine which holds an object value and which is updated by |
| 490 * the garbage collector whenever the object is moved. A new storage | 506 * the garbage collector whenever the object is moved. A new storage |
| 491 * cell can be created using the constructor or Persistent::Reset and | 507 * cell can be created using the constructor or Persistent::Reset and |
| 492 * existing handles can be disposed using Persistent::Reset. | 508 * existing handles can be disposed using Persistent::Reset. |
| (...skipping 3518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4011 */ | 4027 */ |
| 4012 HeapProfiler* GetHeapProfiler(); | 4028 HeapProfiler* GetHeapProfiler(); |
| 4013 | 4029 |
| 4014 /** | 4030 /** |
| 4015 * Returns CPU profiler for this isolate. Will return NULL unless the isolate | 4031 * Returns CPU profiler for this isolate. Will return NULL unless the isolate |
| 4016 * is initialized. It is the embedder's responsibility to stop all CPU | 4032 * is initialized. It is the embedder's responsibility to stop all CPU |
| 4017 * profiling activities if it has started any. | 4033 * profiling activities if it has started any. |
| 4018 */ | 4034 */ |
| 4019 CpuProfiler* GetCpuProfiler(); | 4035 CpuProfiler* GetCpuProfiler(); |
| 4020 | 4036 |
| 4037 /** Returns true if this isolate has a current context. */ |
| 4038 bool InContext(); |
| 4039 |
| 4021 /** Returns the context that is on the top of the stack. */ | 4040 /** Returns the context that is on the top of the stack. */ |
| 4022 Local<Context> GetCurrentContext(); | 4041 Local<Context> GetCurrentContext(); |
| 4023 | 4042 |
| 4024 /** | 4043 /** |
| 4044 * Returns the context of the calling JavaScript code. That is the |
| 4045 * context of the top-most JavaScript frame. If there are no |
| 4046 * JavaScript frames an empty handle is returned. |
| 4047 */ |
| 4048 Local<Context> GetCallingContext(); |
| 4049 |
| 4050 /** Returns the last entered context. */ |
| 4051 Local<Context> GetEnteredContext(); |
| 4052 |
| 4053 /** |
| 4025 * Allows the host application to group objects together. If one | 4054 * Allows the host application to group objects together. If one |
| 4026 * object in the group is alive, all objects in the group are alive. | 4055 * object in the group is alive, all objects in the group are alive. |
| 4027 * After each garbage collection, object groups are removed. It is | 4056 * After each garbage collection, object groups are removed. It is |
| 4028 * intended to be used in the before-garbage-collection callback | 4057 * intended to be used in the before-garbage-collection callback |
| 4029 * function, for instance to simulate DOM tree connections among JS | 4058 * function, for instance to simulate DOM tree connections among JS |
| 4030 * wrapper objects. Object groups for all dependent handles need to | 4059 * wrapper objects. Object groups for all dependent handles need to |
| 4031 * be provided for kGCTypeMarkSweepCompact collections, for all other | 4060 * be provided for kGCTypeMarkSweepCompact collections, for all other |
| 4032 * garbage collection types it is sufficient to provide object groups | 4061 * garbage collection types it is sufficient to provide object groups |
| 4033 * for partially dependent handles only. | 4062 * for partially dependent handles only. |
| 4034 */ | 4063 */ |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4916 * created by a previous call to Context::New with the same global | 4945 * created by a previous call to Context::New with the same global |
| 4917 * template. The state of the global object will be completely reset | 4946 * template. The state of the global object will be completely reset |
| 4918 * and only object identify will remain. | 4947 * and only object identify will remain. |
| 4919 */ | 4948 */ |
| 4920 static Local<Context> New( | 4949 static Local<Context> New( |
| 4921 Isolate* isolate, | 4950 Isolate* isolate, |
| 4922 ExtensionConfiguration* extensions = NULL, | 4951 ExtensionConfiguration* extensions = NULL, |
| 4923 Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), | 4952 Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), |
| 4924 Handle<Value> global_object = Handle<Value>()); | 4953 Handle<Value> global_object = Handle<Value>()); |
| 4925 | 4954 |
| 4926 /** Deprecated. Use Isolate version instead. */ | 4955 // TODO(dcarney): Remove this function. |
| 4927 V8_DEPRECATED(static Persistent<Context> New( | 4956 /** Deprecated. Use Isolate::GetEnteredContext */ |
| 4928 ExtensionConfiguration* extensions = NULL, | |
| 4929 Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), | |
| 4930 Handle<Value> global_object = Handle<Value>())); | |
| 4931 | |
| 4932 /** Returns the last entered context. */ | |
| 4933 static Local<Context> GetEntered(); | 4957 static Local<Context> GetEntered(); |
| 4934 | 4958 |
| 4935 // TODO(svenpanne) Actually deprecate this. | 4959 // TODO(dcarney) Remove this function. |
| 4936 /** Deprecated. Use Isolate::GetCurrentContext instead. */ | 4960 /** Deprecated. Use Isolate::GetCurrentContext instead. */ |
| 4937 static Local<Context> GetCurrent(); | 4961 static Local<Context> GetCurrent(); |
| 4938 | 4962 |
| 4939 /** | 4963 // TODO(dcarney) Remove this function. |
| 4940 * Returns the context of the calling JavaScript code. That is the | 4964 /** Deprecated. Use Isolate::GetCallingContext instead. */ |
| 4941 * context of the top-most JavaScript frame. If there are no | |
| 4942 * JavaScript frames an empty handle is returned. | |
| 4943 */ | |
| 4944 static Local<Context> GetCalling(); | 4965 static Local<Context> GetCalling(); |
| 4945 | 4966 |
| 4946 /** | 4967 /** |
| 4947 * Sets the security token for the context. To access an object in | 4968 * Sets the security token for the context. To access an object in |
| 4948 * another context, the security tokens must match. | 4969 * another context, the security tokens must match. |
| 4949 */ | 4970 */ |
| 4950 void SetSecurityToken(Handle<Value> token); | 4971 void SetSecurityToken(Handle<Value> token); |
| 4951 | 4972 |
| 4952 /** Restores the security token to the default value. */ | 4973 /** Restores the security token to the default value. */ |
| 4953 void UseDefaultSecurityToken(); | 4974 void UseDefaultSecurityToken(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4965 | 4986 |
| 4966 /** | 4987 /** |
| 4967 * Exit this context. Exiting the current context restores the | 4988 * Exit this context. Exiting the current context restores the |
| 4968 * context that was in place when entering the current context. | 4989 * context that was in place when entering the current context. |
| 4969 */ | 4990 */ |
| 4970 void Exit(); | 4991 void Exit(); |
| 4971 | 4992 |
| 4972 /** Returns true if the context has experienced an out of memory situation. */ | 4993 /** Returns true if the context has experienced an out of memory situation. */ |
| 4973 bool HasOutOfMemoryException(); | 4994 bool HasOutOfMemoryException(); |
| 4974 | 4995 |
| 4975 /** Returns true if V8 has a current context. */ | 4996 // TODO(dcarney) Remove this function. |
| 4997 /** Deprecated. Use Isolate::InContext instead. */ |
| 4976 static bool InContext(); | 4998 static bool InContext(); |
| 4977 | 4999 |
| 4978 /** Returns an isolate associated with a current context. */ | 5000 /** Returns an isolate associated with a current context. */ |
| 4979 v8::Isolate* GetIsolate(); | 5001 v8::Isolate* GetIsolate(); |
| 4980 | 5002 |
| 4981 /** | 5003 /** |
| 4982 * Gets the embedder data with the given index, which must have been set by a | 5004 * Gets the embedder data with the given index, which must have been set by a |
| 4983 * previous call to SetEmbedderData with the same index. Note that index 0 | 5005 * previous call to SetEmbedderData with the same index. Note that index 0 |
| 4984 * currently has a special meaning for Chrome's debugger. | 5006 * currently has a special meaning for Chrome's debugger. |
| 4985 */ | 5007 */ |
| (...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6455 */ | 6477 */ |
| 6456 | 6478 |
| 6457 | 6479 |
| 6458 } // namespace v8 | 6480 } // namespace v8 |
| 6459 | 6481 |
| 6460 | 6482 |
| 6461 #undef TYPE_CHECK | 6483 #undef TYPE_CHECK |
| 6462 | 6484 |
| 6463 | 6485 |
| 6464 #endif // V8_H_ | 6486 #endif // V8_H_ |
| OLD | NEW |