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