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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 #define V8EXPORT __attribute__ ((visibility("default"))) | 69 #define V8EXPORT __attribute__ ((visibility("default"))) |
70 #else | 70 #else |
71 #define V8EXPORT | 71 #define V8EXPORT |
72 #endif | 72 #endif |
73 #else | 73 #else |
74 #define V8EXPORT | 74 #define V8EXPORT |
75 #endif | 75 #endif |
76 | 76 |
77 #endif // _WIN32 | 77 #endif // _WIN32 |
78 | 78 |
| 79 #if defined(__GNUC__) && !defined(DEBUG) |
| 80 #define V8_INLINE(declarator) inline __attribute__((always_inline)) declarator |
| 81 #elif defined(_MSC_VER) && !defined(DEBUG) |
| 82 #define V8_INLINE(declarator) __forceinline declarator |
| 83 #else |
| 84 #define V8_INLINE(declarator) inline declarator |
| 85 #endif |
| 86 |
79 #if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS | 87 #if defined(__GNUC__) && !V8_DISABLE_DEPRECATIONS |
80 #define V8_DEPRECATED(func) func __attribute__ ((deprecated)) | 88 #define V8_DEPRECATED(declarator) declarator __attribute__ ((deprecated)) |
81 #elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS | 89 #elif defined(_MSC_VER) && !V8_DISABLE_DEPRECATIONS |
82 #define V8_DEPRECATED(func) __declspec(deprecated) func | 90 #define V8_DEPRECATED(declarator) __declspec(deprecated) declarator |
83 #else | 91 #else |
84 #define V8_DEPRECATED(func) func | 92 #define V8_DEPRECATED(declarator) declarator |
85 #endif | 93 #endif |
86 | 94 |
87 /** | 95 /** |
88 * The v8 JavaScript engine. | 96 * The v8 JavaScript engine. |
89 */ | 97 */ |
90 namespace v8 { | 98 namespace v8 { |
91 | 99 |
92 class Context; | 100 class Context; |
93 class String; | 101 class String; |
94 class StringObject; | 102 class StringObject; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 * dereferencing the handle (for instance, to extract the Object* from | 185 * dereferencing the handle (for instance, to extract the Object* from |
178 * a Handle<Object>); the value will still be governed by a handle | 186 * a Handle<Object>); the value will still be governed by a handle |
179 * behind the scenes and the same rules apply to these values as to | 187 * behind the scenes and the same rules apply to these values as to |
180 * their handles. | 188 * their handles. |
181 */ | 189 */ |
182 template <class T> class Handle { | 190 template <class T> class Handle { |
183 public: | 191 public: |
184 /** | 192 /** |
185 * Creates an empty handle. | 193 * Creates an empty handle. |
186 */ | 194 */ |
187 inline Handle() : val_(0) {} | 195 V8_INLINE(Handle()) : val_(0) {} |
188 | 196 |
189 /** | 197 /** |
190 * Creates a new handle for the specified value. | 198 * Creates a new handle for the specified value. |
191 */ | 199 */ |
192 inline explicit Handle(T* val) : val_(val) {} | 200 V8_INLINE(explicit Handle(T* val)) : val_(val) {} |
193 | 201 |
194 /** | 202 /** |
195 * Creates a handle for the contents of the specified handle. This | 203 * Creates a handle for the contents of the specified handle. This |
196 * constructor allows you to pass handles as arguments by value and | 204 * constructor allows you to pass handles as arguments by value and |
197 * to assign between handles. However, if you try to assign between | 205 * to assign between handles. However, if you try to assign between |
198 * incompatible handles, for instance from a Handle<String> to a | 206 * incompatible handles, for instance from a Handle<String> to a |
199 * Handle<Number> it will cause a compile-time error. Assigning | 207 * Handle<Number> it will cause a compile-time error. Assigning |
200 * between compatible handles, for instance assigning a | 208 * between compatible handles, for instance assigning a |
201 * Handle<String> to a variable declared as Handle<Value>, is legal | 209 * Handle<String> to a variable declared as Handle<Value>, is legal |
202 * because String is a subclass of Value. | 210 * because String is a subclass of Value. |
203 */ | 211 */ |
204 template <class S> inline Handle(Handle<S> that) | 212 template <class S> V8_INLINE(Handle(Handle<S> that)) |
205 : val_(reinterpret_cast<T*>(*that)) { | 213 : val_(reinterpret_cast<T*>(*that)) { |
206 /** | 214 /** |
207 * This check fails when trying to convert between incompatible | 215 * This check fails when trying to convert between incompatible |
208 * handles. For example, converting from a Handle<String> to a | 216 * handles. For example, converting from a Handle<String> to a |
209 * Handle<Number>. | 217 * Handle<Number>. |
210 */ | 218 */ |
211 TYPE_CHECK(T, S); | 219 TYPE_CHECK(T, S); |
212 } | 220 } |
213 | 221 |
214 /** | 222 /** |
215 * Returns true if the handle is empty. | 223 * Returns true if the handle is empty. |
216 */ | 224 */ |
217 inline bool IsEmpty() const { return val_ == 0; } | 225 V8_INLINE(bool IsEmpty() const) { return val_ == 0; } |
218 | 226 |
219 /** | 227 /** |
220 * Sets the handle to be empty. IsEmpty() will then return true. | 228 * Sets the handle to be empty. IsEmpty() will then return true. |
221 */ | 229 */ |
222 inline void Clear() { val_ = 0; } | 230 V8_INLINE(void Clear()) { val_ = 0; } |
223 | 231 |
224 inline T* operator->() const { return val_; } | 232 V8_INLINE(T* operator->() const) { return val_; } |
225 | 233 |
226 inline T* operator*() const { return val_; } | 234 V8_INLINE(T* operator*() const) { return val_; } |
227 | 235 |
228 /** | 236 /** |
229 * Checks whether two handles are the same. | 237 * Checks whether two handles are the same. |
230 * Returns true if both are empty, or if the objects | 238 * Returns true if both are empty, or if the objects |
231 * to which they refer are identical. | 239 * to which they refer are identical. |
232 * The handles' references are not checked. | 240 * The handles' references are not checked. |
233 */ | 241 */ |
234 template <class S> inline bool operator==(Handle<S> that) const { | 242 template <class S> V8_INLINE(bool operator==(Handle<S> that) const) { |
235 internal::Object** a = reinterpret_cast<internal::Object**>(**this); | 243 internal::Object** a = reinterpret_cast<internal::Object**>(**this); |
236 internal::Object** b = reinterpret_cast<internal::Object**>(*that); | 244 internal::Object** b = reinterpret_cast<internal::Object**>(*that); |
237 if (a == 0) return b == 0; | 245 if (a == 0) return b == 0; |
238 if (b == 0) return false; | 246 if (b == 0) return false; |
239 return *a == *b; | 247 return *a == *b; |
240 } | 248 } |
241 | 249 |
242 /** | 250 /** |
243 * Checks whether two handles are different. | 251 * Checks whether two handles are different. |
244 * Returns true if only one of the handles is empty, or if | 252 * Returns true if only one of the handles is empty, or if |
245 * the objects to which they refer are different. | 253 * the objects to which they refer are different. |
246 * The handles' references are not checked. | 254 * The handles' references are not checked. |
247 */ | 255 */ |
248 template <class S> inline bool operator!=(Handle<S> that) const { | 256 template <class S> V8_INLINE(bool operator!=(Handle<S> that) const) { |
249 return !operator==(that); | 257 return !operator==(that); |
250 } | 258 } |
251 | 259 |
252 template <class S> static inline Handle<T> Cast(Handle<S> that) { | 260 template <class S> V8_INLINE(static Handle<T> Cast(Handle<S> that)) { |
253 #ifdef V8_ENABLE_CHECKS | 261 #ifdef V8_ENABLE_CHECKS |
254 // If we're going to perform the type check then we have to check | 262 // If we're going to perform the type check then we have to check |
255 // that the handle isn't empty before doing the checked cast. | 263 // that the handle isn't empty before doing the checked cast. |
256 if (that.IsEmpty()) return Handle<T>(); | 264 if (that.IsEmpty()) return Handle<T>(); |
257 #endif | 265 #endif |
258 return Handle<T>(T::Cast(*that)); | 266 return Handle<T>(T::Cast(*that)); |
259 } | 267 } |
260 | 268 |
261 template <class S> inline Handle<S> As() { | 269 template <class S> V8_INLINE(Handle<S> As()) { |
262 return Handle<S>::Cast(*this); | 270 return Handle<S>::Cast(*this); |
263 } | 271 } |
264 | 272 |
265 private: | 273 private: |
266 T* val_; | 274 T* val_; |
267 }; | 275 }; |
268 | 276 |
269 | 277 |
270 /** | 278 /** |
271 * A light-weight stack-allocated object handle. All operations | 279 * A light-weight stack-allocated object handle. All operations |
272 * that return objects from within v8 return them in local handles. They | 280 * that return objects from within v8 return them in local handles. They |
273 * are created within HandleScopes, and all local handles allocated within a | 281 * are created within HandleScopes, and all local handles allocated within a |
274 * handle scope are destroyed when the handle scope is destroyed. Hence it | 282 * handle scope are destroyed when the handle scope is destroyed. Hence it |
275 * is not necessary to explicitly deallocate local handles. | 283 * is not necessary to explicitly deallocate local handles. |
276 */ | 284 */ |
277 template <class T> class Local : public Handle<T> { | 285 template <class T> class Local : public Handle<T> { |
278 public: | 286 public: |
279 inline Local(); | 287 V8_INLINE(Local()); |
280 template <class S> inline Local(Local<S> that) | 288 template <class S> V8_INLINE(Local(Local<S> that)) |
281 : Handle<T>(reinterpret_cast<T*>(*that)) { | 289 : Handle<T>(reinterpret_cast<T*>(*that)) { |
282 /** | 290 /** |
283 * This check fails when trying to convert between incompatible | 291 * This check fails when trying to convert between incompatible |
284 * handles. For example, converting from a Handle<String> to a | 292 * handles. For example, converting from a Handle<String> to a |
285 * Handle<Number>. | 293 * Handle<Number>. |
286 */ | 294 */ |
287 TYPE_CHECK(T, S); | 295 TYPE_CHECK(T, S); |
288 } | 296 } |
289 template <class S> inline Local(S* that) : Handle<T>(that) { } | 297 template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { } |
290 template <class S> static inline Local<T> Cast(Local<S> that) { | 298 template <class S> V8_INLINE(static Local<T> Cast(Local<S> that)) { |
291 #ifdef V8_ENABLE_CHECKS | 299 #ifdef V8_ENABLE_CHECKS |
292 // If we're going to perform the type check then we have to check | 300 // If we're going to perform the type check then we have to check |
293 // that the handle isn't empty before doing the checked cast. | 301 // that the handle isn't empty before doing the checked cast. |
294 if (that.IsEmpty()) return Local<T>(); | 302 if (that.IsEmpty()) return Local<T>(); |
295 #endif | 303 #endif |
296 return Local<T>(T::Cast(*that)); | 304 return Local<T>(T::Cast(*that)); |
297 } | 305 } |
298 | 306 |
299 template <class S> inline Local<S> As() { | 307 template <class S> V8_INLINE(Local<S> As()) { |
300 return Local<S>::Cast(*this); | 308 return Local<S>::Cast(*this); |
301 } | 309 } |
302 | 310 |
303 /** Create a local handle for the content of another handle. | 311 /** Create a local handle for the content of another handle. |
304 * The referee is kept alive by the local handle even when | 312 * The referee is kept alive by the local handle even when |
305 * the original handle is destroyed/disposed. | 313 * the original handle is destroyed/disposed. |
306 */ | 314 */ |
307 inline static Local<T> New(Handle<T> that); | 315 V8_INLINE(static Local<T> New(Handle<T> that)); |
308 }; | 316 }; |
309 | 317 |
310 | 318 |
311 /** | 319 /** |
312 * An object reference that is independent of any handle scope. Where | 320 * An object reference that is independent of any handle scope. Where |
313 * a Local handle only lives as long as the HandleScope in which it was | 321 * a Local handle only lives as long as the HandleScope in which it was |
314 * allocated, a Persistent handle remains valid until it is explicitly | 322 * allocated, a Persistent handle remains valid until it is explicitly |
315 * disposed. | 323 * disposed. |
316 * | 324 * |
317 * A persistent handle contains a reference to a storage cell within | 325 * A persistent handle contains a reference to a storage cell within |
318 * the v8 engine which holds an object value and which is updated by | 326 * the v8 engine which holds an object value and which is updated by |
319 * the garbage collector whenever the object is moved. A new storage | 327 * the garbage collector whenever the object is moved. A new storage |
320 * cell can be created using Persistent::New and existing handles can | 328 * cell can be created using Persistent::New and existing handles can |
321 * be disposed using Persistent::Dispose. Since persistent handles | 329 * be disposed using Persistent::Dispose. Since persistent handles |
322 * are passed by value you may have many persistent handle objects | 330 * are passed by value you may have many persistent handle objects |
323 * that point to the same storage cell. For instance, if you pass a | 331 * that point to the same storage cell. For instance, if you pass a |
324 * persistent handle as an argument to a function you will not get two | 332 * persistent handle as an argument to a function you will not get two |
325 * different storage cells but rather two references to the same | 333 * different storage cells but rather two references to the same |
326 * storage cell. | 334 * storage cell. |
327 */ | 335 */ |
328 template <class T> class Persistent : public Handle<T> { | 336 template <class T> class Persistent : public Handle<T> { |
329 public: | 337 public: |
330 /** | 338 /** |
331 * Creates an empty persistent handle that doesn't point to any | 339 * Creates an empty persistent handle that doesn't point to any |
332 * storage cell. | 340 * storage cell. |
333 */ | 341 */ |
334 inline Persistent(); | 342 V8_INLINE(Persistent()); |
335 | 343 |
336 /** | 344 /** |
337 * Creates a persistent handle for the same storage cell as the | 345 * Creates a persistent handle for the same storage cell as the |
338 * specified handle. This constructor allows you to pass persistent | 346 * specified handle. This constructor allows you to pass persistent |
339 * handles as arguments by value and to assign between persistent | 347 * handles as arguments by value and to assign between persistent |
340 * handles. However, attempting to assign between incompatible | 348 * handles. However, attempting to assign between incompatible |
341 * persistent handles, for instance from a Persistent<String> to a | 349 * persistent handles, for instance from a Persistent<String> to a |
342 * Persistent<Number> will cause a compile-time error. Assigning | 350 * Persistent<Number> will cause a compile-time error. Assigning |
343 * between compatible persistent handles, for instance assigning a | 351 * between compatible persistent handles, for instance assigning a |
344 * Persistent<String> to a variable declared as Persistent<Value>, | 352 * Persistent<String> to a variable declared as Persistent<Value>, |
345 * is allowed as String is a subclass of Value. | 353 * is allowed as String is a subclass of Value. |
346 */ | 354 */ |
347 template <class S> inline Persistent(Persistent<S> that) | 355 template <class S> V8_INLINE(Persistent(Persistent<S> that)) |
348 : Handle<T>(reinterpret_cast<T*>(*that)) { | 356 : Handle<T>(reinterpret_cast<T*>(*that)) { |
349 /** | 357 /** |
350 * This check fails when trying to convert between incompatible | 358 * This check fails when trying to convert between incompatible |
351 * handles. For example, converting from a Handle<String> to a | 359 * handles. For example, converting from a Handle<String> to a |
352 * Handle<Number>. | 360 * Handle<Number>. |
353 */ | 361 */ |
354 TYPE_CHECK(T, S); | 362 TYPE_CHECK(T, S); |
355 } | 363 } |
356 | 364 |
357 template <class S> inline Persistent(S* that) : Handle<T>(that) { } | 365 template <class S> V8_INLINE(Persistent(S* that)) : Handle<T>(that) { } |
358 | 366 |
359 /** | 367 /** |
360 * "Casts" a plain handle which is known to be a persistent handle | 368 * "Casts" a plain handle which is known to be a persistent handle |
361 * to a persistent handle. | 369 * to a persistent handle. |
362 */ | 370 */ |
363 template <class S> explicit inline Persistent(Handle<S> that) | 371 template <class S> explicit V8_INLINE(Persistent(Handle<S> that)) |
364 : Handle<T>(*that) { } | 372 : Handle<T>(*that) { } |
365 | 373 |
366 template <class S> static inline Persistent<T> Cast(Persistent<S> that) { | 374 template <class S> V8_INLINE(static Persistent<T> Cast(Persistent<S> that)) { |
367 #ifdef V8_ENABLE_CHECKS | 375 #ifdef V8_ENABLE_CHECKS |
368 // If we're going to perform the type check then we have to check | 376 // If we're going to perform the type check then we have to check |
369 // that the handle isn't empty before doing the checked cast. | 377 // that the handle isn't empty before doing the checked cast. |
370 if (that.IsEmpty()) return Persistent<T>(); | 378 if (that.IsEmpty()) return Persistent<T>(); |
371 #endif | 379 #endif |
372 return Persistent<T>(T::Cast(*that)); | 380 return Persistent<T>(T::Cast(*that)); |
373 } | 381 } |
374 | 382 |
375 template <class S> inline Persistent<S> As() { | 383 template <class S> V8_INLINE(Persistent<S> As()) { |
376 return Persistent<S>::Cast(*this); | 384 return Persistent<S>::Cast(*this); |
377 } | 385 } |
378 | 386 |
379 /** | 387 /** |
380 * Creates a new persistent handle for an existing local or | 388 * Creates a new persistent handle for an existing local or |
381 * persistent handle. | 389 * persistent handle. |
382 */ | 390 */ |
383 inline static Persistent<T> New(Handle<T> that); | 391 V8_INLINE(static Persistent<T> New(Handle<T> that)); |
384 | 392 |
385 /** | 393 /** |
386 * Releases the storage cell referenced by this persistent handle. | 394 * Releases the storage cell referenced by this persistent handle. |
387 * Does not remove the reference to the cell from any handles. | 395 * Does not remove the reference to the cell from any handles. |
388 * This handle's reference, and any other references to the storage | 396 * This handle's reference, and any other references to the storage |
389 * cell remain and IsEmpty will still return false. | 397 * cell remain and IsEmpty will still return false. |
390 */ | 398 */ |
391 inline void Dispose(); | 399 V8_INLINE(void Dispose()); |
392 inline void Dispose(Isolate* isolate); | 400 V8_INLINE(void Dispose(Isolate* isolate)); |
393 | 401 |
394 /** | 402 /** |
395 * Make the reference to this object weak. When only weak handles | 403 * Make the reference to this object weak. When only weak handles |
396 * refer to the object, the garbage collector will perform a | 404 * refer to the object, the garbage collector will perform a |
397 * callback to the given V8::WeakReferenceCallback function, passing | 405 * callback to the given V8::WeakReferenceCallback function, passing |
398 * it the object reference and the given parameters. | 406 * it the object reference and the given parameters. |
399 */ | 407 */ |
400 inline void MakeWeak(void* parameters, WeakReferenceCallback callback); | 408 V8_INLINE(void MakeWeak(void* parameters, WeakReferenceCallback callback)); |
401 | 409 |
402 /** Clears the weak reference to this object. */ | 410 /** Clears the weak reference to this object. */ |
403 inline void ClearWeak(); | 411 V8_INLINE(void ClearWeak()); |
404 | 412 |
405 /** | 413 /** |
406 * Marks the reference to this object independent. Garbage collector | 414 * Marks the reference to this object independent. Garbage collector |
407 * is free to ignore any object groups containing this object. | 415 * is free to ignore any object groups containing this object. |
408 * Weak callback for an independent handle should not | 416 * Weak callback for an independent handle should not |
409 * assume that it will be preceded by a global GC prologue callback | 417 * assume that it will be preceded by a global GC prologue callback |
410 * or followed by a global GC epilogue callback. | 418 * or followed by a global GC epilogue callback. |
411 */ | 419 */ |
412 inline void MarkIndependent(); | 420 V8_INLINE(void MarkIndependent()); |
413 inline void MarkIndependent(Isolate* isolate); | 421 V8_INLINE(void MarkIndependent(Isolate* isolate)); |
414 | 422 |
415 /** | 423 /** |
416 * Marks the reference to this object partially dependent. Partially | 424 * Marks the reference to this object partially dependent. Partially |
417 * dependent handles only depend on other partially dependent handles and | 425 * dependent handles only depend on other partially dependent handles and |
418 * these dependencies are provided through object groups. It provides a way | 426 * these dependencies are provided through object groups. It provides a way |
419 * to build smaller object groups for young objects that represent only a | 427 * to build smaller object groups for young objects that represent only a |
420 * subset of all external dependencies. This mark is automatically cleared | 428 * subset of all external dependencies. This mark is automatically cleared |
421 * after each garbage collection. | 429 * after each garbage collection. |
422 */ | 430 */ |
423 inline void MarkPartiallyDependent(); | 431 V8_INLINE(void MarkPartiallyDependent()); |
424 inline void MarkPartiallyDependent(Isolate* isolate); | 432 V8_INLINE(void MarkPartiallyDependent(Isolate* isolate)); |
425 | 433 |
426 /** Returns true if this handle was previously marked as independent. */ | 434 /** Returns true if this handle was previously marked as independent. */ |
427 inline bool IsIndependent() const; | 435 V8_INLINE(bool IsIndependent() const); |
428 inline bool IsIndependent(Isolate* isolate) const; | 436 V8_INLINE(bool IsIndependent(Isolate* isolate) const); |
429 | 437 |
430 /** Checks if the handle holds the only reference to an object. */ | 438 /** Checks if the handle holds the only reference to an object. */ |
431 inline bool IsNearDeath() const; | 439 V8_INLINE(bool IsNearDeath() const); |
432 | 440 |
433 /** Returns true if the handle's reference is weak. */ | 441 /** Returns true if the handle's reference is weak. */ |
434 inline bool IsWeak() const; | 442 V8_INLINE(bool IsWeak() const); |
435 | 443 |
436 /** | 444 /** |
437 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo | 445 * Assigns a wrapper class ID to the handle. See RetainedObjectInfo |
438 * interface description in v8-profiler.h for details. | 446 * interface description in v8-profiler.h for details. |
439 */ | 447 */ |
440 inline void SetWrapperClassId(uint16_t class_id); | 448 V8_INLINE(void SetWrapperClassId(uint16_t class_id)); |
441 | 449 |
442 /** | 450 /** |
443 * Returns the class ID previously assigned to this handle or 0 if no class | 451 * Returns the class ID previously assigned to this handle or 0 if no class |
444 * ID was previously assigned. | 452 * ID was previously assigned. |
445 */ | 453 */ |
446 inline uint16_t WrapperClassId() const; | 454 V8_INLINE(uint16_t WrapperClassId() const); |
447 | 455 |
448 private: | 456 private: |
449 friend class ImplementationUtilities; | 457 friend class ImplementationUtilities; |
450 friend class ObjectTemplate; | 458 friend class ObjectTemplate; |
451 }; | 459 }; |
452 | 460 |
453 | 461 |
454 /** | 462 /** |
455 * A stack-allocated class that governs a number of local handles. | 463 * A stack-allocated class that governs a number of local handles. |
456 * After a handle scope has been created, all local handles will be | 464 * After a handle scope has been created, all local handles will be |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 void* operator new(size_t size); | 505 void* operator new(size_t size); |
498 void operator delete(void*, size_t); | 506 void operator delete(void*, size_t); |
499 | 507 |
500 // This Data class is accessible internally as HandleScopeData through a | 508 // This Data class is accessible internally as HandleScopeData through a |
501 // typedef in the ImplementationUtilities class. | 509 // typedef in the ImplementationUtilities class. |
502 class V8EXPORT Data { | 510 class V8EXPORT Data { |
503 public: | 511 public: |
504 internal::Object** next; | 512 internal::Object** next; |
505 internal::Object** limit; | 513 internal::Object** limit; |
506 int level; | 514 int level; |
507 inline void Initialize() { | 515 V8_INLINE(void Initialize()) { |
508 next = limit = NULL; | 516 next = limit = NULL; |
509 level = 0; | 517 level = 0; |
510 } | 518 } |
511 }; | 519 }; |
512 | 520 |
513 void Leave(); | 521 void Leave(); |
514 | 522 |
515 internal::Isolate* isolate_; | 523 internal::Isolate* isolate_; |
516 internal::Object** prev_next_; | 524 internal::Object** prev_next_; |
517 internal::Object** prev_limit_; | 525 internal::Object** prev_limit_; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 */ | 598 */ |
591 virtual bool HasError() = 0; | 599 virtual bool HasError() = 0; |
592 }; | 600 }; |
593 | 601 |
594 | 602 |
595 /** | 603 /** |
596 * The origin, within a file, of a script. | 604 * The origin, within a file, of a script. |
597 */ | 605 */ |
598 class ScriptOrigin { | 606 class ScriptOrigin { |
599 public: | 607 public: |
600 inline ScriptOrigin( | 608 V8_INLINE(ScriptOrigin( |
601 Handle<Value> resource_name, | 609 Handle<Value> resource_name, |
602 Handle<Integer> resource_line_offset = Handle<Integer>(), | 610 Handle<Integer> resource_line_offset = Handle<Integer>(), |
603 Handle<Integer> resource_column_offset = Handle<Integer>()) | 611 Handle<Integer> resource_column_offset = Handle<Integer>())) |
604 : resource_name_(resource_name), | 612 : resource_name_(resource_name), |
605 resource_line_offset_(resource_line_offset), | 613 resource_line_offset_(resource_line_offset), |
606 resource_column_offset_(resource_column_offset) { } | 614 resource_column_offset_(resource_column_offset) { } |
607 inline Handle<Value> ResourceName() const; | 615 V8_INLINE(Handle<Value> ResourceName() const); |
608 inline Handle<Integer> ResourceLineOffset() const; | 616 V8_INLINE(Handle<Integer> ResourceLineOffset() const); |
609 inline Handle<Integer> ResourceColumnOffset() const; | 617 V8_INLINE(Handle<Integer> ResourceColumnOffset() const); |
610 private: | 618 private: |
611 Handle<Value> resource_name_; | 619 Handle<Value> resource_name_; |
612 Handle<Integer> resource_line_offset_; | 620 Handle<Integer> resource_line_offset_; |
613 Handle<Integer> resource_column_offset_; | 621 Handle<Integer> resource_column_offset_; |
614 }; | 622 }; |
615 | 623 |
616 | 624 |
617 /** | 625 /** |
618 * A compiled JavaScript script. | 626 * A compiled JavaScript script. |
619 */ | 627 */ |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 895 |
888 /** | 896 /** |
889 * The superclass of all JavaScript values and objects. | 897 * The superclass of all JavaScript values and objects. |
890 */ | 898 */ |
891 class Value : public Data { | 899 class Value : public Data { |
892 public: | 900 public: |
893 /** | 901 /** |
894 * Returns true if this value is the undefined value. See ECMA-262 | 902 * Returns true if this value is the undefined value. See ECMA-262 |
895 * 4.3.10. | 903 * 4.3.10. |
896 */ | 904 */ |
897 inline bool IsUndefined() const; | 905 V8_INLINE(bool IsUndefined() const); |
898 | 906 |
899 /** | 907 /** |
900 * Returns true if this value is the null value. See ECMA-262 | 908 * Returns true if this value is the null value. See ECMA-262 |
901 * 4.3.11. | 909 * 4.3.11. |
902 */ | 910 */ |
903 inline bool IsNull() const; | 911 V8_INLINE(bool IsNull() const); |
904 | 912 |
905 /** | 913 /** |
906 * Returns true if this value is true. | 914 * Returns true if this value is true. |
907 */ | 915 */ |
908 V8EXPORT bool IsTrue() const; | 916 V8EXPORT bool IsTrue() const; |
909 | 917 |
910 /** | 918 /** |
911 * Returns true if this value is false. | 919 * Returns true if this value is false. |
912 */ | 920 */ |
913 V8EXPORT bool IsFalse() const; | 921 V8EXPORT bool IsFalse() const; |
914 | 922 |
915 /** | 923 /** |
916 * Returns true if this value is an instance of the String type. | 924 * Returns true if this value is an instance of the String type. |
917 * See ECMA-262 8.4. | 925 * See ECMA-262 8.4. |
918 */ | 926 */ |
919 inline bool IsString() const; | 927 V8_INLINE(bool IsString() const); |
920 | 928 |
921 /** | 929 /** |
922 * Returns true if this value is a function. | 930 * Returns true if this value is a function. |
923 */ | 931 */ |
924 V8EXPORT bool IsFunction() const; | 932 V8EXPORT bool IsFunction() const; |
925 | 933 |
926 /** | 934 /** |
927 * Returns true if this value is an array. | 935 * Returns true if this value is an array. |
928 */ | 936 */ |
929 V8EXPORT bool IsArray() const; | 937 V8EXPORT bool IsArray() const; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 V8EXPORT double NumberValue() const; | 1015 V8EXPORT double NumberValue() const; |
1008 V8EXPORT int64_t IntegerValue() const; | 1016 V8EXPORT int64_t IntegerValue() const; |
1009 V8EXPORT uint32_t Uint32Value() const; | 1017 V8EXPORT uint32_t Uint32Value() const; |
1010 V8EXPORT int32_t Int32Value() const; | 1018 V8EXPORT int32_t Int32Value() const; |
1011 | 1019 |
1012 /** JS == */ | 1020 /** JS == */ |
1013 V8EXPORT bool Equals(Handle<Value> that) const; | 1021 V8EXPORT bool Equals(Handle<Value> that) const; |
1014 V8EXPORT bool StrictEquals(Handle<Value> that) const; | 1022 V8EXPORT bool StrictEquals(Handle<Value> that) const; |
1015 | 1023 |
1016 private: | 1024 private: |
1017 inline bool QuickIsUndefined() const; | 1025 V8_INLINE(bool QuickIsUndefined() const); |
1018 inline bool QuickIsNull() const; | 1026 V8_INLINE(bool QuickIsNull() const); |
1019 inline bool QuickIsString() const; | 1027 V8_INLINE(bool QuickIsString() const); |
1020 V8EXPORT bool FullIsUndefined() const; | 1028 V8EXPORT bool FullIsUndefined() const; |
1021 V8EXPORT bool FullIsNull() const; | 1029 V8EXPORT bool FullIsNull() const; |
1022 V8EXPORT bool FullIsString() const; | 1030 V8EXPORT bool FullIsString() const; |
1023 }; | 1031 }; |
1024 | 1032 |
1025 | 1033 |
1026 /** | 1034 /** |
1027 * The superclass of primitive values. See ECMA-262 4.3.2. | 1035 * The superclass of primitive values. See ECMA-262 4.3.2. |
1028 */ | 1036 */ |
1029 class Primitive : public Value { }; | 1037 class Primitive : public Value { }; |
1030 | 1038 |
1031 | 1039 |
1032 /** | 1040 /** |
1033 * A primitive boolean value (ECMA-262, 4.3.14). Either the true | 1041 * A primitive boolean value (ECMA-262, 4.3.14). Either the true |
1034 * or false value. | 1042 * or false value. |
1035 */ | 1043 */ |
1036 class Boolean : public Primitive { | 1044 class Boolean : public Primitive { |
1037 public: | 1045 public: |
1038 V8EXPORT bool Value() const; | 1046 V8EXPORT bool Value() const; |
1039 static inline Handle<Boolean> New(bool value); | 1047 V8_INLINE(static Handle<Boolean> New(bool value)); |
1040 }; | 1048 }; |
1041 | 1049 |
1042 | 1050 |
1043 /** | 1051 /** |
1044 * A JavaScript string value (ECMA-262, 4.3.17). | 1052 * A JavaScript string value (ECMA-262, 4.3.17). |
1045 */ | 1053 */ |
1046 class String : public Primitive { | 1054 class String : public Primitive { |
1047 public: | 1055 public: |
1048 enum Encoding { | 1056 enum Encoding { |
1049 UNKNOWN_ENCODING = 0x1, | 1057 UNKNOWN_ENCODING = 0x1, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 // UTF-8 encoded characters. | 1122 // UTF-8 encoded characters. |
1115 V8EXPORT int WriteUtf8(char* buffer, | 1123 V8EXPORT int WriteUtf8(char* buffer, |
1116 int length = -1, | 1124 int length = -1, |
1117 int* nchars_ref = NULL, | 1125 int* nchars_ref = NULL, |
1118 int options = NO_OPTIONS) const; | 1126 int options = NO_OPTIONS) const; |
1119 | 1127 |
1120 /** | 1128 /** |
1121 * A zero length string. | 1129 * A zero length string. |
1122 */ | 1130 */ |
1123 V8EXPORT static v8::Local<v8::String> Empty(); | 1131 V8EXPORT static v8::Local<v8::String> Empty(); |
1124 inline static v8::Local<v8::String> Empty(Isolate* isolate); | 1132 V8_INLINE(static v8::Local<v8::String> Empty(Isolate* isolate)); |
1125 | 1133 |
1126 /** | 1134 /** |
1127 * Returns true if the string is external | 1135 * Returns true if the string is external |
1128 */ | 1136 */ |
1129 V8EXPORT bool IsExternal() const; | 1137 V8EXPORT bool IsExternal() const; |
1130 | 1138 |
1131 /** | 1139 /** |
1132 * Returns true if the string is both external and ASCII | 1140 * Returns true if the string is both external and ASCII |
1133 */ | 1141 */ |
1134 V8EXPORT bool IsExternalAscii() const; | 1142 V8EXPORT bool IsExternalAscii() const; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 virtual size_t length() const = 0; | 1218 virtual size_t length() const = 0; |
1211 protected: | 1219 protected: |
1212 ExternalAsciiStringResource() {} | 1220 ExternalAsciiStringResource() {} |
1213 }; | 1221 }; |
1214 | 1222 |
1215 /** | 1223 /** |
1216 * If the string is an external string, return the ExternalStringResourceBase | 1224 * If the string is an external string, return the ExternalStringResourceBase |
1217 * regardless of the encoding, otherwise return NULL. The encoding of the | 1225 * regardless of the encoding, otherwise return NULL. The encoding of the |
1218 * string is returned in encoding_out. | 1226 * string is returned in encoding_out. |
1219 */ | 1227 */ |
1220 inline ExternalStringResourceBase* GetExternalStringResourceBase( | 1228 V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase( |
1221 Encoding* encoding_out) const; | 1229 Encoding* encoding_out) const); |
1222 | 1230 |
1223 /** | 1231 /** |
1224 * Get the ExternalStringResource for an external string. Returns | 1232 * Get the ExternalStringResource for an external string. Returns |
1225 * NULL if IsExternal() doesn't return true. | 1233 * NULL if IsExternal() doesn't return true. |
1226 */ | 1234 */ |
1227 inline ExternalStringResource* GetExternalStringResource() const; | 1235 V8_INLINE(ExternalStringResource* GetExternalStringResource() const); |
1228 | 1236 |
1229 /** | 1237 /** |
1230 * Get the ExternalAsciiStringResource for an external ASCII string. | 1238 * Get the ExternalAsciiStringResource for an external ASCII string. |
1231 * Returns NULL if IsExternalAscii() doesn't return true. | 1239 * Returns NULL if IsExternalAscii() doesn't return true. |
1232 */ | 1240 */ |
1233 V8EXPORT const ExternalAsciiStringResource* GetExternalAsciiStringResource() | 1241 V8EXPORT const ExternalAsciiStringResource* GetExternalAsciiStringResource() |
1234 const; | 1242 const; |
1235 | 1243 |
1236 static inline String* Cast(v8::Value* obj); | 1244 V8_INLINE(static String* Cast(v8::Value* obj)); |
1237 | 1245 |
1238 /** | 1246 /** |
1239 * Allocates a new string from either UTF-8 encoded or ASCII data. | 1247 * Allocates a new string from either UTF-8 encoded or ASCII data. |
1240 * The second parameter 'length' gives the buffer length. | 1248 * The second parameter 'length' gives the buffer length. |
1241 * If the data is UTF-8 encoded, the caller must | 1249 * If the data is UTF-8 encoded, the caller must |
1242 * be careful to supply the length parameter. | 1250 * be careful to supply the length parameter. |
1243 * If it is not given, the function calls | 1251 * If it is not given, the function calls |
1244 * 'strlen' to determine the buffer length, it might be | 1252 * 'strlen' to determine the buffer length, it might be |
1245 * wrong if 'data' contains a null character. | 1253 * wrong if 'data' contains a null character. |
1246 */ | 1254 */ |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 }; | 1398 }; |
1391 | 1399 |
1392 | 1400 |
1393 /** | 1401 /** |
1394 * A JavaScript number value (ECMA-262, 4.3.20) | 1402 * A JavaScript number value (ECMA-262, 4.3.20) |
1395 */ | 1403 */ |
1396 class Number : public Primitive { | 1404 class Number : public Primitive { |
1397 public: | 1405 public: |
1398 V8EXPORT double Value() const; | 1406 V8EXPORT double Value() const; |
1399 V8EXPORT static Local<Number> New(double value); | 1407 V8EXPORT static Local<Number> New(double value); |
1400 static inline Number* Cast(v8::Value* obj); | 1408 V8_INLINE(static Number* Cast(v8::Value* obj)); |
1401 private: | 1409 private: |
1402 V8EXPORT Number(); | 1410 V8EXPORT Number(); |
1403 V8EXPORT static void CheckCast(v8::Value* obj); | 1411 V8EXPORT static void CheckCast(v8::Value* obj); |
1404 }; | 1412 }; |
1405 | 1413 |
1406 | 1414 |
1407 /** | 1415 /** |
1408 * A JavaScript value representing a signed integer. | 1416 * A JavaScript value representing a signed integer. |
1409 */ | 1417 */ |
1410 class Integer : public Number { | 1418 class Integer : public Number { |
1411 public: | 1419 public: |
1412 V8EXPORT static Local<Integer> New(int32_t value); | 1420 V8EXPORT static Local<Integer> New(int32_t value); |
1413 V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value); | 1421 V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value); |
1414 V8EXPORT static Local<Integer> New(int32_t value, Isolate*); | 1422 V8EXPORT static Local<Integer> New(int32_t value, Isolate*); |
1415 V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); | 1423 V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); |
1416 V8EXPORT int64_t Value() const; | 1424 V8EXPORT int64_t Value() const; |
1417 static inline Integer* Cast(v8::Value* obj); | 1425 V8_INLINE(static Integer* Cast(v8::Value* obj)); |
1418 private: | 1426 private: |
1419 V8EXPORT Integer(); | 1427 V8EXPORT Integer(); |
1420 V8EXPORT static void CheckCast(v8::Value* obj); | 1428 V8EXPORT static void CheckCast(v8::Value* obj); |
1421 }; | 1429 }; |
1422 | 1430 |
1423 | 1431 |
1424 /** | 1432 /** |
1425 * A JavaScript value representing a 32-bit signed integer. | 1433 * A JavaScript value representing a 32-bit signed integer. |
1426 */ | 1434 */ |
1427 class Int32 : public Integer { | 1435 class Int32 : public Integer { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 | 1612 |
1605 /** | 1613 /** |
1606 * Returns the name of the function invoked as a constructor for this object. | 1614 * Returns the name of the function invoked as a constructor for this object. |
1607 */ | 1615 */ |
1608 V8EXPORT Local<String> GetConstructorName(); | 1616 V8EXPORT Local<String> GetConstructorName(); |
1609 | 1617 |
1610 /** Gets the number of internal fields for this Object. */ | 1618 /** Gets the number of internal fields for this Object. */ |
1611 V8EXPORT int InternalFieldCount(); | 1619 V8EXPORT int InternalFieldCount(); |
1612 | 1620 |
1613 /** Gets the value from an internal field. */ | 1621 /** Gets the value from an internal field. */ |
1614 inline Local<Value> GetInternalField(int index); | 1622 V8_INLINE(Local<Value> GetInternalField(int index)); |
1615 | 1623 |
1616 /** Sets the value in an internal field. */ | 1624 /** Sets the value in an internal field. */ |
1617 V8EXPORT void SetInternalField(int index, Handle<Value> value); | 1625 V8EXPORT void SetInternalField(int index, Handle<Value> value); |
1618 | 1626 |
1619 /** | 1627 /** |
1620 * Gets a native pointer from an internal field. Deprecated. If the pointer is | 1628 * Gets a native pointer from an internal field. Deprecated. If the pointer is |
1621 * always 2-byte-aligned, use GetAlignedPointerFromInternalField instead, | 1629 * always 2-byte-aligned, use GetAlignedPointerFromInternalField instead, |
1622 * otherwise use a combination of GetInternalField, External::Cast and | 1630 * otherwise use a combination of GetInternalField, External::Cast and |
1623 * External::Value. | 1631 * External::Value. |
1624 */ | 1632 */ |
1625 V8EXPORT V8_DEPRECATED(void* GetPointerFromInternalField(int index)); | 1633 V8EXPORT V8_DEPRECATED(void* GetPointerFromInternalField(int index)); |
1626 | 1634 |
1627 /** | 1635 /** |
1628 * Sets a native pointer in an internal field. Deprecated. If the pointer is | 1636 * Sets a native pointer in an internal field. Deprecated. If the pointer is |
1629 * always 2-byte aligned, use SetAlignedPointerInInternalField instead, | 1637 * always 2-byte aligned, use SetAlignedPointerInInternalField instead, |
1630 * otherwise use a combination of External::New and SetInternalField. | 1638 * otherwise use a combination of External::New and SetInternalField. |
1631 */ | 1639 */ |
1632 inline V8_DEPRECATED(void SetPointerInInternalField(int index, void* value)); | 1640 V8_DEPRECATED(V8_INLINE(void SetPointerInInternalField(int index, |
| 1641 void* value))); |
1633 | 1642 |
1634 /** | 1643 /** |
1635 * Gets a 2-byte-aligned native pointer from an internal field. This field | 1644 * Gets a 2-byte-aligned native pointer from an internal field. This field |
1636 * must have been set by SetAlignedPointerInInternalField, everything else | 1645 * must have been set by SetAlignedPointerInInternalField, everything else |
1637 * leads to undefined behavior. | 1646 * leads to undefined behavior. |
1638 */ | 1647 */ |
1639 inline void* GetAlignedPointerFromInternalField(int index); | 1648 V8_INLINE(void* GetAlignedPointerFromInternalField(int index)); |
1640 | 1649 |
1641 /** | 1650 /** |
1642 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such | 1651 * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such |
1643 * a field, GetAlignedPointerFromInternalField must be used, everything else | 1652 * a field, GetAlignedPointerFromInternalField must be used, everything else |
1644 * leads to undefined behavior. | 1653 * leads to undefined behavior. |
1645 */ | 1654 */ |
1646 V8EXPORT void SetAlignedPointerInInternalField(int index, void* value); | 1655 V8EXPORT void SetAlignedPointerInInternalField(int index, void* value); |
1647 | 1656 |
1648 // Testers for local properties. | 1657 // Testers for local properties. |
1649 V8EXPORT bool HasOwnProperty(Handle<String> key); | 1658 V8EXPORT bool HasOwnProperty(Handle<String> key); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 | 1771 |
1763 /** | 1772 /** |
1764 * Call an Object as a constructor if a callback is set by the | 1773 * Call an Object as a constructor if a callback is set by the |
1765 * ObjectTemplate::SetCallAsFunctionHandler method. | 1774 * ObjectTemplate::SetCallAsFunctionHandler method. |
1766 * Note: This method behaves like the Function::NewInstance method. | 1775 * Note: This method behaves like the Function::NewInstance method. |
1767 */ | 1776 */ |
1768 V8EXPORT Local<Value> CallAsConstructor(int argc, | 1777 V8EXPORT Local<Value> CallAsConstructor(int argc, |
1769 Handle<Value> argv[]); | 1778 Handle<Value> argv[]); |
1770 | 1779 |
1771 V8EXPORT static Local<Object> New(); | 1780 V8EXPORT static Local<Object> New(); |
1772 static inline Object* Cast(Value* obj); | 1781 V8_INLINE(static Object* Cast(Value* obj)); |
1773 | 1782 |
1774 private: | 1783 private: |
1775 V8EXPORT Object(); | 1784 V8EXPORT Object(); |
1776 V8EXPORT static void CheckCast(Value* obj); | 1785 V8EXPORT static void CheckCast(Value* obj); |
1777 V8EXPORT Local<Value> SlowGetInternalField(int index); | 1786 V8EXPORT Local<Value> SlowGetInternalField(int index); |
1778 V8EXPORT void* SlowGetAlignedPointerFromInternalField(int index); | 1787 V8EXPORT void* SlowGetAlignedPointerFromInternalField(int index); |
1779 }; | 1788 }; |
1780 | 1789 |
1781 | 1790 |
1782 /** | 1791 /** |
1783 * An instance of the built-in array constructor (ECMA-262, 15.4.2). | 1792 * An instance of the built-in array constructor (ECMA-262, 15.4.2). |
1784 */ | 1793 */ |
1785 class Array : public Object { | 1794 class Array : public Object { |
1786 public: | 1795 public: |
1787 V8EXPORT uint32_t Length() const; | 1796 V8EXPORT uint32_t Length() const; |
1788 | 1797 |
1789 /** | 1798 /** |
1790 * Clones an element at index |index|. Returns an empty | 1799 * Clones an element at index |index|. Returns an empty |
1791 * handle if cloning fails (for any reason). | 1800 * handle if cloning fails (for any reason). |
1792 */ | 1801 */ |
1793 V8EXPORT Local<Object> CloneElementAt(uint32_t index); | 1802 V8EXPORT Local<Object> CloneElementAt(uint32_t index); |
1794 | 1803 |
1795 /** | 1804 /** |
1796 * Creates a JavaScript array with the given length. If the length | 1805 * Creates a JavaScript array with the given length. If the length |
1797 * is negative the returned array will have length 0. | 1806 * is negative the returned array will have length 0. |
1798 */ | 1807 */ |
1799 V8EXPORT static Local<Array> New(int length = 0); | 1808 V8EXPORT static Local<Array> New(int length = 0); |
1800 | 1809 |
1801 static inline Array* Cast(Value* obj); | 1810 V8_INLINE(static Array* Cast(Value* obj)); |
1802 private: | 1811 private: |
1803 V8EXPORT Array(); | 1812 V8EXPORT Array(); |
1804 V8EXPORT static void CheckCast(Value* obj); | 1813 V8EXPORT static void CheckCast(Value* obj); |
1805 }; | 1814 }; |
1806 | 1815 |
1807 | 1816 |
1808 /** | 1817 /** |
1809 * A JavaScript function object (ECMA-262, 15.3). | 1818 * A JavaScript function object (ECMA-262, 15.3). |
1810 */ | 1819 */ |
1811 class Function : public Object { | 1820 class Function : public Object { |
(...skipping 19 matching lines...) Expand all Loading... |
1831 * kLineOffsetNotFound if no information available. | 1840 * kLineOffsetNotFound if no information available. |
1832 */ | 1841 */ |
1833 V8EXPORT int GetScriptLineNumber() const; | 1842 V8EXPORT int GetScriptLineNumber() const; |
1834 /** | 1843 /** |
1835 * Returns zero based column number of function body and | 1844 * Returns zero based column number of function body and |
1836 * kLineOffsetNotFound if no information available. | 1845 * kLineOffsetNotFound if no information available. |
1837 */ | 1846 */ |
1838 V8EXPORT int GetScriptColumnNumber() const; | 1847 V8EXPORT int GetScriptColumnNumber() const; |
1839 V8EXPORT Handle<Value> GetScriptId() const; | 1848 V8EXPORT Handle<Value> GetScriptId() const; |
1840 V8EXPORT ScriptOrigin GetScriptOrigin() const; | 1849 V8EXPORT ScriptOrigin GetScriptOrigin() const; |
1841 static inline Function* Cast(Value* obj); | 1850 V8_INLINE(static Function* Cast(Value* obj)); |
1842 V8EXPORT static const int kLineOffsetNotFound; | 1851 V8EXPORT static const int kLineOffsetNotFound; |
1843 | 1852 |
1844 private: | 1853 private: |
1845 V8EXPORT Function(); | 1854 V8EXPORT Function(); |
1846 V8EXPORT static void CheckCast(Value* obj); | 1855 V8EXPORT static void CheckCast(Value* obj); |
1847 }; | 1856 }; |
1848 | 1857 |
1849 | 1858 |
1850 /** | 1859 /** |
1851 * An instance of the built-in Date constructor (ECMA-262, 15.9). | 1860 * An instance of the built-in Date constructor (ECMA-262, 15.9). |
1852 */ | 1861 */ |
1853 class Date : public Object { | 1862 class Date : public Object { |
1854 public: | 1863 public: |
1855 V8EXPORT static Local<Value> New(double time); | 1864 V8EXPORT static Local<Value> New(double time); |
1856 | 1865 |
1857 /** | 1866 /** |
1858 * A specialization of Value::NumberValue that is more efficient | 1867 * A specialization of Value::NumberValue that is more efficient |
1859 * because we know the structure of this object. | 1868 * because we know the structure of this object. |
1860 */ | 1869 */ |
1861 V8EXPORT double NumberValue() const; | 1870 V8EXPORT double NumberValue() const; |
1862 | 1871 |
1863 static inline Date* Cast(v8::Value* obj); | 1872 V8_INLINE(static Date* Cast(v8::Value* obj)); |
1864 | 1873 |
1865 /** | 1874 /** |
1866 * Notification that the embedder has changed the time zone, | 1875 * Notification that the embedder has changed the time zone, |
1867 * daylight savings time, or other date / time configuration | 1876 * daylight savings time, or other date / time configuration |
1868 * parameters. V8 keeps a cache of various values used for | 1877 * parameters. V8 keeps a cache of various values used for |
1869 * date / time computation. This notification will reset | 1878 * date / time computation. This notification will reset |
1870 * those cached values for the current context so that date / | 1879 * those cached values for the current context so that date / |
1871 * time configuration changes would be reflected in the Date | 1880 * time configuration changes would be reflected in the Date |
1872 * object. | 1881 * object. |
1873 * | 1882 * |
(...skipping 12 matching lines...) Expand all Loading... |
1886 */ | 1895 */ |
1887 class NumberObject : public Object { | 1896 class NumberObject : public Object { |
1888 public: | 1897 public: |
1889 V8EXPORT static Local<Value> New(double value); | 1898 V8EXPORT static Local<Value> New(double value); |
1890 | 1899 |
1891 /** | 1900 /** |
1892 * Returns the Number held by the object. | 1901 * Returns the Number held by the object. |
1893 */ | 1902 */ |
1894 V8EXPORT double NumberValue() const; | 1903 V8EXPORT double NumberValue() const; |
1895 | 1904 |
1896 static inline NumberObject* Cast(v8::Value* obj); | 1905 V8_INLINE(static NumberObject* Cast(v8::Value* obj)); |
1897 | 1906 |
1898 private: | 1907 private: |
1899 V8EXPORT static void CheckCast(v8::Value* obj); | 1908 V8EXPORT static void CheckCast(v8::Value* obj); |
1900 }; | 1909 }; |
1901 | 1910 |
1902 | 1911 |
1903 /** | 1912 /** |
1904 * A Boolean object (ECMA-262, 4.3.15). | 1913 * A Boolean object (ECMA-262, 4.3.15). |
1905 */ | 1914 */ |
1906 class BooleanObject : public Object { | 1915 class BooleanObject : public Object { |
1907 public: | 1916 public: |
1908 V8EXPORT static Local<Value> New(bool value); | 1917 V8EXPORT static Local<Value> New(bool value); |
1909 | 1918 |
1910 /** | 1919 /** |
1911 * Returns the Boolean held by the object. | 1920 * Returns the Boolean held by the object. |
1912 */ | 1921 */ |
1913 V8EXPORT bool BooleanValue() const; | 1922 V8EXPORT bool BooleanValue() const; |
1914 | 1923 |
1915 static inline BooleanObject* Cast(v8::Value* obj); | 1924 V8_INLINE(static BooleanObject* Cast(v8::Value* obj)); |
1916 | 1925 |
1917 private: | 1926 private: |
1918 V8EXPORT static void CheckCast(v8::Value* obj); | 1927 V8EXPORT static void CheckCast(v8::Value* obj); |
1919 }; | 1928 }; |
1920 | 1929 |
1921 | 1930 |
1922 /** | 1931 /** |
1923 * A String object (ECMA-262, 4.3.18). | 1932 * A String object (ECMA-262, 4.3.18). |
1924 */ | 1933 */ |
1925 class StringObject : public Object { | 1934 class StringObject : public Object { |
1926 public: | 1935 public: |
1927 V8EXPORT static Local<Value> New(Handle<String> value); | 1936 V8EXPORT static Local<Value> New(Handle<String> value); |
1928 | 1937 |
1929 /** | 1938 /** |
1930 * Returns the String held by the object. | 1939 * Returns the String held by the object. |
1931 */ | 1940 */ |
1932 V8EXPORT Local<String> StringValue() const; | 1941 V8EXPORT Local<String> StringValue() const; |
1933 | 1942 |
1934 static inline StringObject* Cast(v8::Value* obj); | 1943 V8_INLINE(static StringObject* Cast(v8::Value* obj)); |
1935 | 1944 |
1936 private: | 1945 private: |
1937 V8EXPORT static void CheckCast(v8::Value* obj); | 1946 V8EXPORT static void CheckCast(v8::Value* obj); |
1938 }; | 1947 }; |
1939 | 1948 |
1940 | 1949 |
1941 /** | 1950 /** |
1942 * An instance of the built-in RegExp constructor (ECMA-262, 15.10). | 1951 * An instance of the built-in RegExp constructor (ECMA-262, 15.10). |
1943 */ | 1952 */ |
1944 class RegExp : public Object { | 1953 class RegExp : public Object { |
(...skipping 26 matching lines...) Expand all Loading... |
1971 * Returns the value of the source property: a string representing | 1980 * Returns the value of the source property: a string representing |
1972 * the regular expression. | 1981 * the regular expression. |
1973 */ | 1982 */ |
1974 V8EXPORT Local<String> GetSource() const; | 1983 V8EXPORT Local<String> GetSource() const; |
1975 | 1984 |
1976 /** | 1985 /** |
1977 * Returns the flags bit field. | 1986 * Returns the flags bit field. |
1978 */ | 1987 */ |
1979 V8EXPORT Flags GetFlags() const; | 1988 V8EXPORT Flags GetFlags() const; |
1980 | 1989 |
1981 static inline RegExp* Cast(v8::Value* obj); | 1990 V8_INLINE(static RegExp* Cast(v8::Value* obj)); |
1982 | 1991 |
1983 private: | 1992 private: |
1984 V8EXPORT static void CheckCast(v8::Value* obj); | 1993 V8EXPORT static void CheckCast(v8::Value* obj); |
1985 }; | 1994 }; |
1986 | 1995 |
1987 | 1996 |
1988 /** | 1997 /** |
1989 * A JavaScript value that wraps a C++ void*. This type of value is mainly used | 1998 * A JavaScript value that wraps a C++ void*. This type of value is mainly used |
1990 * to associate C++ data structures with JavaScript objects. | 1999 * to associate C++ data structures with JavaScript objects. |
1991 */ | 2000 */ |
1992 class External : public Value { | 2001 class External : public Value { |
1993 public: | 2002 public: |
1994 /** Deprecated, use New instead. */ | 2003 /** Deprecated, use New instead. */ |
1995 V8_DEPRECATED(static inline Local<Value> Wrap(void* value)); | 2004 V8_DEPRECATED(V8_INLINE(static Local<Value> Wrap(void* value))); |
1996 | 2005 |
1997 /** Deprecated, use a combination of Cast and Value instead. */ | 2006 /** Deprecated, use a combination of Cast and Value instead. */ |
1998 V8_DEPRECATED(static inline void* Unwrap(Handle<Value> obj)); | 2007 V8_DEPRECATED(V8_INLINE(static void* Unwrap(Handle<Value> obj))); |
1999 | 2008 |
2000 V8EXPORT static Local<External> New(void* value); | 2009 V8EXPORT static Local<External> New(void* value); |
2001 static inline External* Cast(Value* obj); | 2010 V8_INLINE(static External* Cast(Value* obj)); |
2002 V8EXPORT void* Value() const; | 2011 V8EXPORT void* Value() const; |
2003 private: | 2012 private: |
2004 V8EXPORT static void CheckCast(v8::Value* obj); | 2013 V8EXPORT static void CheckCast(v8::Value* obj); |
2005 }; | 2014 }; |
2006 | 2015 |
2007 | 2016 |
2008 // --- Templates --- | 2017 // --- Templates --- |
2009 | 2018 |
2010 | 2019 |
2011 /** | 2020 /** |
2012 * The superclass of object and function templates. | 2021 * The superclass of object and function templates. |
2013 */ | 2022 */ |
2014 class V8EXPORT Template : public Data { | 2023 class V8EXPORT Template : public Data { |
2015 public: | 2024 public: |
2016 /** Adds a property to each instance created by this template.*/ | 2025 /** Adds a property to each instance created by this template.*/ |
2017 void Set(Handle<String> name, Handle<Data> value, | 2026 void Set(Handle<String> name, Handle<Data> value, |
2018 PropertyAttribute attributes = None); | 2027 PropertyAttribute attributes = None); |
2019 inline void Set(const char* name, Handle<Data> value); | 2028 V8_INLINE(void Set(const char* name, Handle<Data> value)); |
2020 private: | 2029 private: |
2021 Template(); | 2030 Template(); |
2022 | 2031 |
2023 friend class ObjectTemplate; | 2032 friend class ObjectTemplate; |
2024 friend class FunctionTemplate; | 2033 friend class FunctionTemplate; |
2025 }; | 2034 }; |
2026 | 2035 |
2027 | 2036 |
2028 /** | 2037 /** |
2029 * The argument information given to function call callbacks. This | 2038 * The argument information given to function call callbacks. This |
2030 * class provides access to information about the context of the call, | 2039 * class provides access to information about the context of the call, |
2031 * including the receiver, the number and values of arguments, and | 2040 * including the receiver, the number and values of arguments, and |
2032 * the holder of the function. | 2041 * the holder of the function. |
2033 */ | 2042 */ |
2034 class Arguments { | 2043 class Arguments { |
2035 public: | 2044 public: |
2036 inline int Length() const; | 2045 V8_INLINE(int Length() const); |
2037 inline Local<Value> operator[](int i) const; | 2046 V8_INLINE(Local<Value> operator[](int i) const); |
2038 inline Local<Function> Callee() const; | 2047 V8_INLINE(Local<Function> Callee() const); |
2039 inline Local<Object> This() const; | 2048 V8_INLINE(Local<Object> This() const); |
2040 inline Local<Object> Holder() const; | 2049 V8_INLINE(Local<Object> Holder() const); |
2041 inline bool IsConstructCall() const; | 2050 V8_INLINE(bool IsConstructCall() const); |
2042 inline Local<Value> Data() const; | 2051 V8_INLINE(Local<Value> Data() const); |
2043 inline Isolate* GetIsolate() const; | 2052 V8_INLINE(Isolate* GetIsolate() const); |
2044 | 2053 |
2045 private: | 2054 private: |
2046 static const int kIsolateIndex = 0; | 2055 static const int kIsolateIndex = 0; |
2047 static const int kDataIndex = -1; | 2056 static const int kDataIndex = -1; |
2048 static const int kCalleeIndex = -2; | 2057 static const int kCalleeIndex = -2; |
2049 static const int kHolderIndex = -3; | 2058 static const int kHolderIndex = -3; |
2050 | 2059 |
2051 friend class ImplementationUtilities; | 2060 friend class ImplementationUtilities; |
2052 inline Arguments(internal::Object** implicit_args, | 2061 V8_INLINE(Arguments(internal::Object** implicit_args, |
2053 internal::Object** values, | 2062 internal::Object** values, |
2054 int length, | 2063 int length, |
2055 bool is_construct_call); | 2064 bool is_construct_call)); |
2056 internal::Object** implicit_args_; | 2065 internal::Object** implicit_args_; |
2057 internal::Object** values_; | 2066 internal::Object** values_; |
2058 int length_; | 2067 int length_; |
2059 bool is_construct_call_; | 2068 bool is_construct_call_; |
2060 }; | 2069 }; |
2061 | 2070 |
2062 | 2071 |
2063 /** | 2072 /** |
2064 * The information passed to an accessor callback about the context | 2073 * The information passed to an accessor callback about the context |
2065 * of the property access. | 2074 * of the property access. |
2066 */ | 2075 */ |
2067 class V8EXPORT AccessorInfo { | 2076 class V8EXPORT AccessorInfo { |
2068 public: | 2077 public: |
2069 inline AccessorInfo(internal::Object** args) | 2078 V8_INLINE(AccessorInfo(internal::Object** args)) |
2070 : args_(args) { } | 2079 : args_(args) { } |
2071 inline Isolate* GetIsolate() const; | 2080 V8_INLINE(Isolate* GetIsolate() const); |
2072 inline Local<Value> Data() const; | 2081 V8_INLINE(Local<Value> Data() const); |
2073 inline Local<Object> This() const; | 2082 V8_INLINE(Local<Object> This() const); |
2074 inline Local<Object> Holder() const; | 2083 V8_INLINE(Local<Object> Holder() const); |
2075 | 2084 |
2076 private: | 2085 private: |
2077 internal::Object** args_; | 2086 internal::Object** args_; |
2078 }; | 2087 }; |
2079 | 2088 |
2080 | 2089 |
2081 typedef Handle<Value> (*InvocationCallback)(const Arguments& args); | 2090 typedef Handle<Value> (*InvocationCallback)(const Arguments& args); |
2082 | 2091 |
2083 /** | 2092 /** |
2084 * NamedProperty[Getter|Setter] are used as interceptors on object. | 2093 * NamedProperty[Getter|Setter] are used as interceptors on object. |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2629 | 2638 |
2630 | 2639 |
2631 void V8EXPORT RegisterExtension(Extension* extension); | 2640 void V8EXPORT RegisterExtension(Extension* extension); |
2632 | 2641 |
2633 | 2642 |
2634 /** | 2643 /** |
2635 * Ignore | 2644 * Ignore |
2636 */ | 2645 */ |
2637 class V8EXPORT DeclareExtension { | 2646 class V8EXPORT DeclareExtension { |
2638 public: | 2647 public: |
2639 inline DeclareExtension(Extension* extension) { | 2648 V8_INLINE(DeclareExtension(Extension* extension)) { |
2640 RegisterExtension(extension); | 2649 RegisterExtension(extension); |
2641 } | 2650 } |
2642 }; | 2651 }; |
2643 | 2652 |
2644 | 2653 |
2645 // --- Statics --- | 2654 // --- Statics --- |
2646 | 2655 |
2647 | 2656 |
2648 Handle<Primitive> V8EXPORT Undefined(); | 2657 Handle<Primitive> V8EXPORT Undefined(); |
2649 Handle<Primitive> V8EXPORT Null(); | 2658 Handle<Primitive> V8EXPORT Null(); |
2650 Handle<Boolean> V8EXPORT True(); | 2659 Handle<Boolean> V8EXPORT True(); |
2651 Handle<Boolean> V8EXPORT False(); | 2660 Handle<Boolean> V8EXPORT False(); |
2652 | 2661 |
2653 inline Handle<Primitive> Undefined(Isolate* isolate); | 2662 V8_INLINE(Handle<Primitive> Undefined(Isolate* isolate)); |
2654 inline Handle<Primitive> Null(Isolate* isolate); | 2663 V8_INLINE(Handle<Primitive> Null(Isolate* isolate)); |
2655 inline Handle<Boolean> True(Isolate* isolate); | 2664 V8_INLINE(Handle<Boolean> True(Isolate* isolate)); |
2656 inline Handle<Boolean> False(Isolate* isolate); | 2665 V8_INLINE(Handle<Boolean> False(Isolate* isolate)); |
2657 | 2666 |
2658 | 2667 |
2659 /** | 2668 /** |
2660 * A set of constraints that specifies the limits of the runtime's memory use. | 2669 * A set of constraints that specifies the limits of the runtime's memory use. |
2661 * You must set the heap size before initializing the VM - the size cannot be | 2670 * You must set the heap size before initializing the VM - the size cannot be |
2662 * adjusted after the VM is initialized. | 2671 * adjusted after the VM is initialized. |
2663 * | 2672 * |
2664 * If you are using threads then you should hold the V8::Locker lock while | 2673 * If you are using threads then you should hold the V8::Locker lock while |
2665 * setting the stack limit and you must set a non-default stack limit separately | 2674 * setting the stack limit and you must set a non-default stack limit separately |
2666 * for each thread. | 2675 * for each thread. |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2903 | 2912 |
2904 /** | 2913 /** |
2905 * Disposes the isolate. The isolate must not be entered by any | 2914 * Disposes the isolate. The isolate must not be entered by any |
2906 * thread to be disposable. | 2915 * thread to be disposable. |
2907 */ | 2916 */ |
2908 void Dispose(); | 2917 void Dispose(); |
2909 | 2918 |
2910 /** | 2919 /** |
2911 * Associate embedder-specific data with the isolate | 2920 * Associate embedder-specific data with the isolate |
2912 */ | 2921 */ |
2913 inline void SetData(void* data); | 2922 V8_INLINE(void SetData(void* data)); |
2914 | 2923 |
2915 /** | 2924 /** |
2916 * Retrieve embedder-specific data from the isolate. | 2925 * Retrieve embedder-specific data from the isolate. |
2917 * Returns NULL if SetData has never been called. | 2926 * Returns NULL if SetData has never been called. |
2918 */ | 2927 */ |
2919 inline void* GetData(); | 2928 V8_INLINE(void* GetData()); |
2920 | 2929 |
2921 private: | 2930 private: |
2922 Isolate(); | 2931 Isolate(); |
2923 Isolate(const Isolate&); | 2932 Isolate(const Isolate&); |
2924 ~Isolate(); | 2933 ~Isolate(); |
2925 Isolate& operator=(const Isolate&); | 2934 Isolate& operator=(const Isolate&); |
2926 void* operator new(size_t size); | 2935 void* operator new(size_t size); |
2927 void operator delete(void*, size_t); | 2936 void operator delete(void*, size_t); |
2928 }; | 2937 }; |
2929 | 2938 |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3794 /** Returns true if the context has experienced an out of memory situation. */ | 3803 /** Returns true if the context has experienced an out of memory situation. */ |
3795 bool HasOutOfMemoryException(); | 3804 bool HasOutOfMemoryException(); |
3796 | 3805 |
3797 /** Returns true if V8 has a current context. */ | 3806 /** Returns true if V8 has a current context. */ |
3798 static bool InContext(); | 3807 static bool InContext(); |
3799 | 3808 |
3800 /** | 3809 /** |
3801 * Gets embedder data with index 0. Deprecated, use GetEmbedderData with index | 3810 * Gets embedder data with index 0. Deprecated, use GetEmbedderData with index |
3802 * 0 instead. | 3811 * 0 instead. |
3803 */ | 3812 */ |
3804 V8_DEPRECATED(inline Local<Value> GetData()); | 3813 V8_DEPRECATED(V8_INLINE(Local<Value> GetData())); |
3805 | 3814 |
3806 /** | 3815 /** |
3807 * Sets embedder data with index 0. Deprecated, use SetEmbedderData with index | 3816 * Sets embedder data with index 0. Deprecated, use SetEmbedderData with index |
3808 * 0 instead. | 3817 * 0 instead. |
3809 */ | 3818 */ |
3810 V8_DEPRECATED(inline void SetData(Handle<Value> value)); | 3819 V8_DEPRECATED(V8_INLINE(void SetData(Handle<Value> value))); |
3811 | 3820 |
3812 /** | 3821 /** |
3813 * Gets the embedder data with the given index, which must have been set by a | 3822 * Gets the embedder data with the given index, which must have been set by a |
3814 * previous call to SetEmbedderData with the same index. Note that index 0 | 3823 * previous call to SetEmbedderData with the same index. Note that index 0 |
3815 * currently has a special meaning for Chrome's debugger. | 3824 * currently has a special meaning for Chrome's debugger. |
3816 */ | 3825 */ |
3817 inline Local<Value> GetEmbedderData(int index); | 3826 V8_INLINE(Local<Value> GetEmbedderData(int index)); |
3818 | 3827 |
3819 /** | 3828 /** |
3820 * Sets the embedder data with the given index, growing the data as | 3829 * Sets the embedder data with the given index, growing the data as |
3821 * needed. Note that index 0 currently has a special meaning for Chrome's | 3830 * needed. Note that index 0 currently has a special meaning for Chrome's |
3822 * debugger. | 3831 * debugger. |
3823 */ | 3832 */ |
3824 void SetEmbedderData(int index, Handle<Value> value); | 3833 void SetEmbedderData(int index, Handle<Value> value); |
3825 | 3834 |
3826 /** | 3835 /** |
3827 * Gets a 2-byte-aligned native pointer from the embedder data with the given | 3836 * Gets a 2-byte-aligned native pointer from the embedder data with the given |
3828 * index, which must have bees set by a previous call to | 3837 * index, which must have bees set by a previous call to |
3829 * SetAlignedPointerInEmbedderData with the same index. Note that index 0 | 3838 * SetAlignedPointerInEmbedderData with the same index. Note that index 0 |
3830 * currently has a special meaning for Chrome's debugger. | 3839 * currently has a special meaning for Chrome's debugger. |
3831 */ | 3840 */ |
3832 inline void* GetAlignedPointerFromEmbedderData(int index); | 3841 V8_INLINE(void* GetAlignedPointerFromEmbedderData(int index)); |
3833 | 3842 |
3834 /** | 3843 /** |
3835 * Sets a 2-byte-aligned native pointer in the embedder data with the given | 3844 * Sets a 2-byte-aligned native pointer in the embedder data with the given |
3836 * index, growing the data as needed. Note that index 0 currently has a | 3845 * index, growing the data as needed. Note that index 0 currently has a |
3837 * special meaning for Chrome's debugger. | 3846 * special meaning for Chrome's debugger. |
3838 */ | 3847 */ |
3839 void SetAlignedPointerInEmbedderData(int index, void* value); | 3848 void SetAlignedPointerInEmbedderData(int index, void* value); |
3840 | 3849 |
3841 /** | 3850 /** |
3842 * Control whether code generation from strings is allowed. Calling | 3851 * Control whether code generation from strings is allowed. Calling |
(...skipping 22 matching lines...) Expand all Loading... |
3865 * constructor are called. | 3874 * constructor are called. |
3866 */ | 3875 */ |
3867 void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message); | 3876 void SetErrorMessageForCodeGenerationFromStrings(Handle<String> message); |
3868 | 3877 |
3869 /** | 3878 /** |
3870 * Stack-allocated class which sets the execution context for all | 3879 * Stack-allocated class which sets the execution context for all |
3871 * operations executed within a local scope. | 3880 * operations executed within a local scope. |
3872 */ | 3881 */ |
3873 class Scope { | 3882 class Scope { |
3874 public: | 3883 public: |
3875 explicit inline Scope(Handle<Context> context) : context_(context) { | 3884 explicit V8_INLINE(Scope(Handle<Context> context)) : context_(context) { |
3876 context_->Enter(); | 3885 context_->Enter(); |
3877 } | 3886 } |
3878 inline ~Scope() { context_->Exit(); } | 3887 V8_INLINE(~Scope()) { context_->Exit(); } |
3879 private: | 3888 private: |
3880 Handle<Context> context_; | 3889 Handle<Context> context_; |
3881 }; | 3890 }; |
3882 | 3891 |
3883 private: | 3892 private: |
3884 friend class Value; | 3893 friend class Value; |
3885 friend class Script; | 3894 friend class Script; |
3886 friend class Object; | 3895 friend class Object; |
3887 friend class Function; | 3896 friend class Function; |
3888 | 3897 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4109 const int kSmiTag = 0; | 4118 const int kSmiTag = 0; |
4110 const int kSmiTagSize = 1; | 4119 const int kSmiTagSize = 1; |
4111 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; | 4120 const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; |
4112 | 4121 |
4113 template <size_t ptr_size> struct SmiTagging; | 4122 template <size_t ptr_size> struct SmiTagging; |
4114 | 4123 |
4115 // Smi constants for 32-bit systems. | 4124 // Smi constants for 32-bit systems. |
4116 template <> struct SmiTagging<4> { | 4125 template <> struct SmiTagging<4> { |
4117 static const int kSmiShiftSize = 0; | 4126 static const int kSmiShiftSize = 0; |
4118 static const int kSmiValueSize = 31; | 4127 static const int kSmiValueSize = 31; |
4119 static inline int SmiToInt(internal::Object* value) { | 4128 V8_INLINE(static int SmiToInt(internal::Object* value)) { |
4120 int shift_bits = kSmiTagSize + kSmiShiftSize; | 4129 int shift_bits = kSmiTagSize + kSmiShiftSize; |
4121 // Throw away top 32 bits and shift down (requires >> to be sign extending). | 4130 // Throw away top 32 bits and shift down (requires >> to be sign extending). |
4122 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits; | 4131 return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits; |
4123 } | 4132 } |
4124 }; | 4133 }; |
4125 | 4134 |
4126 // Smi constants for 64-bit systems. | 4135 // Smi constants for 64-bit systems. |
4127 template <> struct SmiTagging<8> { | 4136 template <> struct SmiTagging<8> { |
4128 static const int kSmiShiftSize = 31; | 4137 static const int kSmiShiftSize = 31; |
4129 static const int kSmiValueSize = 32; | 4138 static const int kSmiValueSize = 32; |
4130 static inline int SmiToInt(internal::Object* value) { | 4139 V8_INLINE(static int SmiToInt(internal::Object* value)) { |
4131 int shift_bits = kSmiTagSize + kSmiShiftSize; | 4140 int shift_bits = kSmiTagSize + kSmiShiftSize; |
4132 // Shift down and throw away top 32 bits. | 4141 // Shift down and throw away top 32 bits. |
4133 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); | 4142 return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); |
4134 } | 4143 } |
4135 }; | 4144 }; |
4136 | 4145 |
4137 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; | 4146 typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; |
4138 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; | 4147 const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; |
4139 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; | 4148 const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; |
4140 | 4149 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4172 static const int kEmptySymbolRootIndex = 119; | 4181 static const int kEmptySymbolRootIndex = 119; |
4173 | 4182 |
4174 static const int kJSObjectType = 0xaa; | 4183 static const int kJSObjectType = 0xaa; |
4175 static const int kFirstNonstringType = 0x80; | 4184 static const int kFirstNonstringType = 0x80; |
4176 static const int kOddballType = 0x82; | 4185 static const int kOddballType = 0x82; |
4177 static const int kForeignType = 0x85; | 4186 static const int kForeignType = 0x85; |
4178 | 4187 |
4179 static const int kUndefinedOddballKind = 5; | 4188 static const int kUndefinedOddballKind = 5; |
4180 static const int kNullOddballKind = 3; | 4189 static const int kNullOddballKind = 3; |
4181 | 4190 |
4182 static inline bool HasHeapObjectTag(internal::Object* value) { | 4191 V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { |
4183 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | 4192 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == |
4184 kHeapObjectTag); | 4193 kHeapObjectTag); |
4185 } | 4194 } |
4186 | 4195 |
4187 static inline int SmiValue(internal::Object* value) { | 4196 V8_INLINE(static int SmiValue(internal::Object* value)) { |
4188 return PlatformSmiTagging::SmiToInt(value); | 4197 return PlatformSmiTagging::SmiToInt(value); |
4189 } | 4198 } |
4190 | 4199 |
4191 static inline int GetInstanceType(internal::Object* obj) { | 4200 V8_INLINE(static int GetInstanceType(internal::Object* obj)) { |
4192 typedef internal::Object O; | 4201 typedef internal::Object O; |
4193 O* map = ReadField<O*>(obj, kHeapObjectMapOffset); | 4202 O* map = ReadField<O*>(obj, kHeapObjectMapOffset); |
4194 return ReadField<uint8_t>(map, kMapInstanceTypeOffset); | 4203 return ReadField<uint8_t>(map, kMapInstanceTypeOffset); |
4195 } | 4204 } |
4196 | 4205 |
4197 static inline int GetOddballKind(internal::Object* obj) { | 4206 V8_INLINE(static int GetOddballKind(internal::Object* obj)) { |
4198 typedef internal::Object O; | 4207 typedef internal::Object O; |
4199 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); | 4208 return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); |
4200 } | 4209 } |
4201 | 4210 |
4202 static inline bool IsExternalTwoByteString(int instance_type) { | 4211 V8_INLINE(static bool IsExternalTwoByteString(int instance_type)) { |
4203 int representation = (instance_type & kFullStringRepresentationMask); | 4212 int representation = (instance_type & kFullStringRepresentationMask); |
4204 return representation == kExternalTwoByteRepresentationTag; | 4213 return representation == kExternalTwoByteRepresentationTag; |
4205 } | 4214 } |
4206 | 4215 |
4207 static inline bool IsInitialized(v8::Isolate* isolate) { | 4216 V8_INLINE(static bool IsInitialized(v8::Isolate* isolate)) { |
4208 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset; | 4217 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset; |
4209 return *reinterpret_cast<int*>(addr) == 1; | 4218 return *reinterpret_cast<int*>(addr) == 1; |
4210 } | 4219 } |
4211 | 4220 |
4212 static inline void SetEmbedderData(v8::Isolate* isolate, void* data) { | 4221 V8_INLINE(static void SetEmbedderData(v8::Isolate* isolate, void* data)) { |
4213 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | 4222 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + |
4214 kIsolateEmbedderDataOffset; | 4223 kIsolateEmbedderDataOffset; |
4215 *reinterpret_cast<void**>(addr) = data; | 4224 *reinterpret_cast<void**>(addr) = data; |
4216 } | 4225 } |
4217 | 4226 |
4218 static inline void* GetEmbedderData(v8::Isolate* isolate) { | 4227 V8_INLINE(static void* GetEmbedderData(v8::Isolate* isolate)) { |
4219 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | 4228 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + |
4220 kIsolateEmbedderDataOffset; | 4229 kIsolateEmbedderDataOffset; |
4221 return *reinterpret_cast<void**>(addr); | 4230 return *reinterpret_cast<void**>(addr); |
4222 } | 4231 } |
4223 | 4232 |
4224 static inline internal::Object** GetRoot(v8::Isolate* isolate, int index) { | 4233 V8_INLINE(static internal::Object** GetRoot(v8::Isolate* isolate, |
| 4234 int index)) { |
4225 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; | 4235 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; |
4226 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); | 4236 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); |
4227 } | 4237 } |
4228 | 4238 |
4229 template <typename T> | 4239 template <typename T> |
4230 static inline T ReadField(Object* ptr, int offset) { | 4240 V8_INLINE(static T ReadField(Object* ptr, int offset)) { |
4231 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; | 4241 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; |
4232 return *reinterpret_cast<T*>(addr); | 4242 return *reinterpret_cast<T*>(addr); |
4233 } | 4243 } |
4234 | 4244 |
4235 template <typename T> | 4245 template <typename T> |
4236 static inline T ReadEmbedderData(Context* context, int index) { | 4246 V8_INLINE(static T ReadEmbedderData(Context* context, int index)) { |
4237 typedef internal::Object O; | 4247 typedef internal::Object O; |
4238 typedef internal::Internals I; | 4248 typedef internal::Internals I; |
4239 O* ctx = *reinterpret_cast<O**>(context); | 4249 O* ctx = *reinterpret_cast<O**>(context); |
4240 int embedder_data_offset = I::kContextHeaderSize + | 4250 int embedder_data_offset = I::kContextHeaderSize + |
4241 (internal::kApiPointerSize * I::kContextEmbedderDataIndex); | 4251 (internal::kApiPointerSize * I::kContextEmbedderDataIndex); |
4242 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); | 4252 O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); |
4243 int value_offset = | 4253 int value_offset = |
4244 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); | 4254 I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); |
4245 return I::ReadField<T>(embedder_data, value_offset); | 4255 return I::ReadField<T>(embedder_data, value_offset); |
4246 } | 4256 } |
4247 | 4257 |
4248 static inline bool CanCastToHeapObject(void* o) { return false; } | 4258 V8_INLINE(static bool CanCastToHeapObject(void* o)) { return false; } |
4249 static inline bool CanCastToHeapObject(Context* o) { return true; } | 4259 V8_INLINE(static bool CanCastToHeapObject(Context* o)) { return true; } |
4250 static inline bool CanCastToHeapObject(String* o) { return true; } | 4260 V8_INLINE(static bool CanCastToHeapObject(String* o)) { return true; } |
4251 static inline bool CanCastToHeapObject(Object* o) { return true; } | 4261 V8_INLINE(static bool CanCastToHeapObject(Object* o)) { return true; } |
4252 static inline bool CanCastToHeapObject(Message* o) { return true; } | 4262 V8_INLINE(static bool CanCastToHeapObject(Message* o)) { return true; } |
4253 static inline bool CanCastToHeapObject(StackTrace* o) { return true; } | 4263 V8_INLINE(static bool CanCastToHeapObject(StackTrace* o)) { return true; } |
4254 static inline bool CanCastToHeapObject(StackFrame* o) { return true; } | 4264 V8_INLINE(static bool CanCastToHeapObject(StackFrame* o)) { return true; } |
4255 }; | 4265 }; |
4256 | 4266 |
4257 } // namespace internal | 4267 } // namespace internal |
4258 | 4268 |
4259 | 4269 |
4260 template <class T> | 4270 template <class T> |
4261 Local<T>::Local() : Handle<T>() { } | 4271 Local<T>::Local() : Handle<T>() { } |
4262 | 4272 |
4263 | 4273 |
4264 template <class T> | 4274 template <class T> |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4814 | 4824 |
4815 | 4825 |
4816 } // namespace v8 | 4826 } // namespace v8 |
4817 | 4827 |
4818 | 4828 |
4819 #undef V8EXPORT | 4829 #undef V8EXPORT |
4820 #undef TYPE_CHECK | 4830 #undef TYPE_CHECK |
4821 | 4831 |
4822 | 4832 |
4823 #endif // V8_H_ | 4833 #endif // V8_H_ |
OLD | NEW |