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 2798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2809 | 2809 |
2810 /** | 2810 /** |
2811 * Disposes the isolate. The isolate must not be entered by any | 2811 * Disposes the isolate. The isolate must not be entered by any |
2812 * thread to be disposable. | 2812 * thread to be disposable. |
2813 */ | 2813 */ |
2814 void Dispose(); | 2814 void Dispose(); |
2815 | 2815 |
2816 /** | 2816 /** |
2817 * Associate embedder-specific data with the isolate | 2817 * Associate embedder-specific data with the isolate |
2818 */ | 2818 */ |
2819 void SetData(void* data); | 2819 inline void SetData(void* data); |
2820 | 2820 |
2821 /** | 2821 /** |
2822 * Retrive embedder-specific data from the isolate. | 2822 * Retrive embedder-specific data from the isolate. |
Sven Panne
2012/04/24 14:14:32
Not caused by you, but a correct spelling would be
Michael Starzinger
2012/04/24 14:33:19
Done.
| |
2823 * Returns NULL if SetData has never been called. | 2823 * Returns NULL if SetData has never been called. |
2824 */ | 2824 */ |
2825 void* GetData(); | 2825 inline void* GetData(); |
2826 | 2826 |
2827 private: | 2827 private: |
2828 Isolate(); | 2828 Isolate(); |
2829 Isolate(const Isolate&); | 2829 Isolate(const Isolate&); |
2830 ~Isolate(); | 2830 ~Isolate(); |
2831 Isolate& operator=(const Isolate&); | 2831 Isolate& operator=(const Isolate&); |
2832 void* operator new(size_t size); | 2832 void* operator new(size_t size); |
2833 void operator delete(void*, size_t); | 2833 void operator delete(void*, size_t); |
2834 }; | 2834 }; |
2835 | 2835 |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3954 static inline bool IsExternalTwoByteString(int instance_type) { | 3954 static inline bool IsExternalTwoByteString(int instance_type) { |
3955 int representation = (instance_type & kFullStringRepresentationMask); | 3955 int representation = (instance_type & kFullStringRepresentationMask); |
3956 return representation == kExternalTwoByteRepresentationTag; | 3956 return representation == kExternalTwoByteRepresentationTag; |
3957 } | 3957 } |
3958 | 3958 |
3959 static inline bool IsInitialized(v8::Isolate* isolate) { | 3959 static inline bool IsInitialized(v8::Isolate* isolate) { |
3960 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset; | 3960 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateStateOffset; |
3961 return *reinterpret_cast<int*>(addr) == 1; | 3961 return *reinterpret_cast<int*>(addr) == 1; |
3962 } | 3962 } |
3963 | 3963 |
3964 static inline void SetEmbedderData(v8::Isolate* isolate, void* data) { | |
3965 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | |
3966 kIsolateEmbedderDataOffset; | |
3967 *reinterpret_cast<void**>(addr) = data; | |
3968 } | |
3969 | |
3970 static inline void* GetEmbedderData(v8::Isolate* isolate) { | |
3971 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + | |
3972 kIsolateEmbedderDataOffset; | |
3973 return *reinterpret_cast<void**>(addr); | |
3974 } | |
3975 | |
3964 static inline internal::Object** GetRoot(v8::Isolate* isolate, int index) { | 3976 static inline internal::Object** GetRoot(v8::Isolate* isolate, int index) { |
3965 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; | 3977 uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; |
3966 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); | 3978 return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); |
3967 } | 3979 } |
3968 | 3980 |
3969 template <typename T> | 3981 template <typename T> |
3970 static inline T ReadField(Object* ptr, int offset) { | 3982 static inline T ReadField(Object* ptr, int offset) { |
3971 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; | 3983 uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; |
3972 return *reinterpret_cast<T*>(addr); | 3984 return *reinterpret_cast<T*>(addr); |
3973 } | 3985 } |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4417 | 4429 |
4418 Handle<Boolean> False(Isolate* isolate) { | 4430 Handle<Boolean> False(Isolate* isolate) { |
4419 typedef internal::Object* S; | 4431 typedef internal::Object* S; |
4420 typedef internal::Internals I; | 4432 typedef internal::Internals I; |
4421 if (!I::IsInitialized(isolate)) return False(); | 4433 if (!I::IsInitialized(isolate)) return False(); |
4422 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); | 4434 S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); |
4423 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); | 4435 return Handle<Boolean>(reinterpret_cast<Boolean*>(slot)); |
4424 } | 4436 } |
4425 | 4437 |
4426 | 4438 |
4439 void Isolate::SetData(void* data) { | |
4440 typedef internal::Internals I; | |
4441 I::SetEmbedderData(this, data); | |
4442 } | |
4443 | |
4444 | |
4445 void* Isolate::GetData() { | |
4446 typedef internal::Internals I; | |
4447 return I::GetEmbedderData(this); | |
4448 } | |
4449 | |
4450 | |
4427 /** | 4451 /** |
4428 * \example shell.cc | 4452 * \example shell.cc |
4429 * A simple shell that takes a list of expressions on the | 4453 * A simple shell that takes a list of expressions on the |
4430 * command-line and executes them. | 4454 * command-line and executes them. |
4431 */ | 4455 */ |
4432 | 4456 |
4433 | 4457 |
4434 /** | 4458 /** |
4435 * \example process.cc | 4459 * \example process.cc |
4436 */ | 4460 */ |
4437 | 4461 |
4438 | 4462 |
4439 } // namespace v8 | 4463 } // namespace v8 |
4440 | 4464 |
4441 | 4465 |
4442 #undef V8EXPORT | 4466 #undef V8EXPORT |
4443 #undef TYPE_CHECK | 4467 #undef TYPE_CHECK |
4444 | 4468 |
4445 | 4469 |
4446 #endif // V8_H_ | 4470 #endif // V8_H_ |
OLD | NEW |