| 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 2543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2554 | 2554 |
| 2555 | 2555 |
| 2556 // --- Statics --- | 2556 // --- Statics --- |
| 2557 | 2557 |
| 2558 | 2558 |
| 2559 Handle<Primitive> V8EXPORT Undefined(); | 2559 Handle<Primitive> V8EXPORT Undefined(); |
| 2560 Handle<Primitive> V8EXPORT Null(); | 2560 Handle<Primitive> V8EXPORT Null(); |
| 2561 Handle<Boolean> V8EXPORT True(); | 2561 Handle<Boolean> V8EXPORT True(); |
| 2562 Handle<Boolean> V8EXPORT False(); | 2562 Handle<Boolean> V8EXPORT False(); |
| 2563 | 2563 |
| 2564 inline Handle<Primitive> Undefined(Isolate* isolate); | |
| 2565 inline Handle<Primitive> Null(Isolate* isolate); | |
| 2566 inline Handle<Boolean> True(Isolate* isolate); | |
| 2567 inline Handle<Boolean> False(Isolate* isolate); | |
| 2568 | |
| 2569 | 2564 |
| 2570 /** | 2565 /** |
| 2571 * A set of constraints that specifies the limits of the runtime's memory use. | 2566 * A set of constraints that specifies the limits of the runtime's memory use. |
| 2572 * You must set the heap size before initializing the VM - the size cannot be | 2567 * You must set the heap size before initializing the VM - the size cannot be |
| 2573 * adjusted after the VM is initialized. | 2568 * adjusted after the VM is initialized. |
| 2574 * | 2569 * |
| 2575 * If you are using threads then you should hold the V8::Locker lock while | 2570 * If you are using threads then you should hold the V8::Locker lock while |
| 2576 * setting the stack limit and you must set a non-default stack limit separately | 2571 * setting the stack limit and you must set a non-default stack limit separately |
| 2577 * for each thread. | 2572 * for each thread. |
| 2578 */ | 2573 */ |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3902 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize; | 3897 static const int kMapInstanceTypeOffset = 1 * kApiPointerSize + kApiIntSize; |
| 3903 static const int kStringResourceOffset = | 3898 static const int kStringResourceOffset = |
| 3904 InternalConstants<kApiPointerSize>::kStringResourceOffset; | 3899 InternalConstants<kApiPointerSize>::kStringResourceOffset; |
| 3905 | 3900 |
| 3906 static const int kOddballKindOffset = 3 * kApiPointerSize; | 3901 static const int kOddballKindOffset = 3 * kApiPointerSize; |
| 3907 static const int kForeignAddressOffset = kApiPointerSize; | 3902 static const int kForeignAddressOffset = kApiPointerSize; |
| 3908 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; | 3903 static const int kJSObjectHeaderSize = 3 * kApiPointerSize; |
| 3909 static const int kFullStringRepresentationMask = 0x07; | 3904 static const int kFullStringRepresentationMask = 0x07; |
| 3910 static const int kExternalTwoByteRepresentationTag = 0x02; | 3905 static const int kExternalTwoByteRepresentationTag = 0x02; |
| 3911 | 3906 |
| 3912 static const int kIsolateStateOffset = 0; | |
| 3913 static const int kIsolateRootsOffset = 2 * kApiPointerSize; | |
| 3914 static const int kUndefinedValueRootIndex = 5; | |
| 3915 static const int kNullValueRootIndex = 7; | |
| 3916 static const int kTrueValueRootIndex = 8; | |
| 3917 static const int kFalseValueRootIndex = 9; | |
| 3918 | |
| 3919 static const int kJSObjectType = 0xaa; | 3907 static const int kJSObjectType = 0xaa; |
| 3920 static const int kFirstNonstringType = 0x80; | 3908 static const int kFirstNonstringType = 0x80; |
| 3921 static const int kOddballType = 0x82; | 3909 static const int kOddballType = 0x82; |
| 3922 static const int kForeignType = 0x85; | 3910 static const int kForeignType = 0x85; |
| 3923 | 3911 |
| 3924 static const int kUndefinedOddballKind = 5; | 3912 static const int kUndefinedOddballKind = 5; |
| 3925 static const int kNullOddballKind = 3; | 3913 static const int kNullOddballKind = 3; |
| 3926 | 3914 |
| 3927 static inline bool HasHeapObjectTag(internal::Object* value) { | 3915 static inline bool HasHeapObjectTag(internal::Object* value) { |
| 3928 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == | 3916 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3961 } else { | 3949 } else { |
| 3962 return NULL; | 3950 return NULL; |
| 3963 } | 3951 } |
| 3964 } | 3952 } |
| 3965 | 3953 |
| 3966 static inline bool IsExternalTwoByteString(int instance_type) { | 3954 static inline bool IsExternalTwoByteString(int instance_type) { |
| 3967 int representation = (instance_type & kFullStringRepresentationMask); | 3955 int representation = (instance_type & kFullStringRepresentationMask); |
| 3968 return representation == kExternalTwoByteRepresentationTag; | 3956 return representation == kExternalTwoByteRepresentationTag; |
| 3969 } | 3957 } |
| 3970 | 3958 |
| 3971 static inline bool IsInitialized(v8::Isolate* isolate) { | |
| 3972 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset; | |
| 3973 return *reinterpret_cast<int*>(addr) == 1; | |
| 3974 } | |
| 3975 | |
| 3976 static inline internal::Object** GetRoot(v8::Isolate* isolate, int index) { | |
| 3977 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; | |
| 3978 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); | |
| 3979 } | |
| 3980 | |
| 3981 template <typename T> | 3959 template <typename T> |
| 3982 static inline T ReadField(Object* ptr, int offset) { | 3960 static inline T ReadField(Object* ptr, int offset) { |
| 3983 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; | 3961 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; |
| 3984 return *reinterpret_cast<T*>(addr); | 3962 return *reinterpret_cast<T*>(addr); |
| 3985 } | 3963 } |
| 3986 | 3964 |
| 3987 static inline bool CanCastToHeapObject(void* o) { return false; } | 3965 static inline bool CanCastToHeapObject(void* o) { return false; } |
| 3988 static inline bool CanCastToHeapObject(Context* o) { return true; } | 3966 static inline bool CanCastToHeapObject(Context* o) { return true; } |
| 3989 static inline bool CanCastToHeapObject(String* o) { return true; } | 3967 static inline bool CanCastToHeapObject(String* o) { return true; } |
| 3990 static inline bool CanCastToHeapObject(Object* o) { return true; } | 3968 static inline bool CanCastToHeapObject(Object* o) { return true; } |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4393 Local<Object> AccessorInfo::This() const { | 4371 Local<Object> AccessorInfo::This() const { |
| 4394 return Local<Object>(reinterpret_cast<Object*>(&args_[0])); | 4372 return Local<Object>(reinterpret_cast<Object*>(&args_[0])); |
| 4395 } | 4373 } |
| 4396 | 4374 |
| 4397 | 4375 |
| 4398 Local<Object> AccessorInfo::Holder() const { | 4376 Local<Object> AccessorInfo::Holder() const { |
| 4399 return Local<Object>(reinterpret_cast<Object*>(&args_[-1])); | 4377 return Local<Object>(reinterpret_cast<Object*>(&args_[-1])); |
| 4400 } | 4378 } |
| 4401 | 4379 |
| 4402 | 4380 |
| 4403 Handle<Primitive> Undefined(Isolate* isolate) { | |
| 4404 typedef internal::Object* S; | |
| 4405 typedef internal::Internals I; | |
| 4406 if (!I::IsInitialized(isolate)) return Undefined(); | |
| 4407 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); | |
| 4408 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); | |
| 4409 } | |
| 4410 | |
| 4411 | |
| 4412 Handle<Primitive> Null(Isolate* isolate) { | |
| 4413 typedef internal::Object* S; | |
| 4414 typedef internal::Internals I; | |
| 4415 if (!I::IsInitialized(isolate)) return Null(); | |
| 4416 S* slot = I::GetRoot(isolate, I::kNullValueRootIndex); | |
| 4417 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); | |
| 4418 } | |
| 4419 | |
| 4420 | |
| 4421 Handle<Boolean> True(Isolate* isolate) { | |
| 4422 typedef internal::Object* S; | |
| 4423 typedef internal::Internals I; | |
| 4424 if (!I::IsInitialized(isolate)) return True(); | |
| 4425 S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex); | |
| 4426 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | |
| 4427 } | |
| 4428 | |
| 4429 | |
| 4430 Handle<Boolean> False(Isolate* isolate) { | |
| 4431 typedef internal::Object* S; | |
| 4432 typedef internal::Internals I; | |
| 4433 if (!I::IsInitialized(isolate)) return False(); | |
| 4434 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); | |
| 4435 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | |
| 4436 } | |
| 4437 | |
| 4438 | |
| 4439 /** | 4381 /** |
| 4440 * \example shell.cc | 4382 * \example shell.cc |
| 4441 * A simple shell that takes a list of expressions on the | 4383 * A simple shell that takes a list of expressions on the |
| 4442 * command-line and executes them. | 4384 * command-line and executes them. |
| 4443 */ | 4385 */ |
| 4444 | 4386 |
| 4445 | 4387 |
| 4446 /** | 4388 /** |
| 4447 * \example process.cc | 4389 * \example process.cc |
| 4448 */ | 4390 */ |
| 4449 | 4391 |
| 4450 | 4392 |
| 4451 } // namespace v8 | 4393 } // namespace v8 |
| 4452 | 4394 |
| 4453 | 4395 |
| 4454 #undef V8EXPORT | 4396 #undef V8EXPORT |
| 4455 #undef TYPE_CHECK | 4397 #undef TYPE_CHECK |
| 4456 | 4398 |
| 4457 | 4399 |
| 4458 #endif // V8_H_ | 4400 #endif // V8_H_ |
| OLD | NEW |