diff options
Diffstat (limited to 'include')
-rwxr-xr-x | include/v8-debug.h | 4 | ||||
-rw-r--r-- | include/v8.h | 100 | ||||
-rw-r--r-- | include/v8stdint.h | 53 |
3 files changed, 98 insertions, 59 deletions
diff --git a/include/v8-debug.h b/include/v8-debug.h index 4314727a..f17b8485 100755 --- a/include/v8-debug.h +++ b/include/v8-debug.h @@ -142,7 +142,7 @@ class EXPORT Debug { virtual ~Message() {} }; - + /** * An event details object passed to the debug event listener. @@ -300,7 +300,7 @@ class EXPORT Debug { * get access to information otherwise not available during normal JavaScript * execution e.g. details on stack frames. Receiver of the function call will * be the debugger context global object, however this is a subject to change. - * The following example show a JavaScript function which when passed to + * The following example show a JavaScript function which when passed to * v8::Debug::Call will return the current line of JavaScript execution. * * \code diff --git a/include/v8.h b/include/v8.h index 89502cb9..8c730df8 100644 --- a/include/v8.h +++ b/include/v8.h @@ -38,23 +38,9 @@ #ifndef V8_H_ #define V8_H_ -#include <stdio.h> +#include "v8stdint.h" #ifdef _WIN32 -// When compiling on MinGW stdint.h is available. -#ifdef __MINGW32__ -#include <stdint.h> -#else // __MINGW32__ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; // NOLINT -typedef unsigned short uint16_t; // NOLINT -typedef int int32_t; -typedef unsigned int uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -// intptr_t and friends are defined in crtdefs.h through stdio.h. -#endif // __MINGW32__ // Setup for Windows DLL export/import. When building the V8 DLL the // BUILDING_V8_SHARED needs to be defined. When building a program which uses @@ -76,8 +62,6 @@ typedef unsigned __int64 uint64_t; #else // _WIN32 -#include <stdint.h> - // Setup for Linux shared library export. There is no need to distinguish // between building or using the V8 shared library, but we should not // export symbols when we are building a static library. @@ -127,7 +111,6 @@ class Arguments; class Object; class Heap; class Top; - } @@ -476,10 +459,10 @@ class V8EXPORT HandleScope { level = 0; } }; - + void Leave(); - + internal::Object** prev_next_; internal::Object** prev_limit_; @@ -1055,7 +1038,7 @@ class String : public Primitive { */ V8EXPORT bool IsExternalAscii() const; - class V8EXPORT ExternalStringResourceBase { + class V8EXPORT ExternalStringResourceBase { // NOLINT public: virtual ~ExternalStringResourceBase() {} @@ -1790,18 +1773,19 @@ class Arguments { inline bool IsConstructCall() const; inline Local<Value> Data() const; private: + static const int kDataIndex = 0; + static const int kCalleeIndex = -1; + static const int kHolderIndex = -2; + friend class ImplementationUtilities; - inline Arguments(Local<Value> data, - Local<Object> holder, - Local<Function> callee, - bool is_construct_call, - void** values, int length); - Local<Value> data_; - Local<Object> holder_; - Local<Function> callee_; - bool is_construct_call_; - void** values_; + inline Arguments(internal::Object** implicit_args, + internal::Object** values, + int length, + bool is_construct_call); + internal::Object** implicit_args_; + internal::Object** values_; int length_; + bool is_construct_call_; }; @@ -3259,8 +3243,8 @@ class V8EXPORT Locker { /** * An interface for exporting data from V8, using "push" model. */ -class V8EXPORT OutputStream { -public: +class V8EXPORT OutputStream { // NOLINT + public: enum OutputEncoding { kAscii = 0 // 7-bit ASCII. }; @@ -3290,6 +3274,8 @@ public: namespace internal { +const int kPointerSize = sizeof(void*); // NOLINT +const int kIntSize = sizeof(int); // NOLINT // Tag information for HeapObject. const int kHeapObjectTag = 1; @@ -3325,19 +3311,19 @@ template <> struct SmiConstants<8> { } }; -const int kSmiShiftSize = SmiConstants<sizeof(void*)>::kSmiShiftSize; -const int kSmiValueSize = SmiConstants<sizeof(void*)>::kSmiValueSize; +const int kSmiShiftSize = SmiConstants<kPointerSize>::kSmiShiftSize; +const int kSmiValueSize = SmiConstants<kPointerSize>::kSmiValueSize; template <size_t ptr_size> struct InternalConstants; // Internal constants for 32-bit systems. template <> struct InternalConstants<4> { - static const int kStringResourceOffset = 3 * sizeof(void*); + static const int kStringResourceOffset = 3 * kPointerSize; }; // Internal constants for 64-bit systems. template <> struct InternalConstants<8> { - static const int kStringResourceOffset = 3 * sizeof(void*); + static const int kStringResourceOffset = 3 * kPointerSize; }; /** @@ -3351,12 +3337,12 @@ class Internals { // These values match non-compiler-dependent values defined within // the implementation of v8. static const int kHeapObjectMapOffset = 0; - static const int kMapInstanceTypeOffset = sizeof(void*) + sizeof(int); + static const int kMapInstanceTypeOffset = kPointerSize + kIntSize; static const int kStringResourceOffset = - InternalConstants<sizeof(void*)>::kStringResourceOffset; + InternalConstants<kPointerSize>::kStringResourceOffset; - static const int kProxyProxyOffset = sizeof(void*); - static const int kJSObjectHeaderSize = 3 * sizeof(void*); + static const int kProxyProxyOffset = kPointerSize; + static const int kJSObjectHeaderSize = 3 * kPointerSize; static const int kFullStringRepresentationMask = 0x07; static const int kExternalTwoByteRepresentationTag = 0x02; @@ -3374,7 +3360,7 @@ class Internals { } static inline int SmiValue(internal::Object* value) { - return SmiConstants<sizeof(void*)>::SmiToInt(value); + return SmiConstants<kPointerSize>::SmiToInt(value); } static inline int GetInstanceType(internal::Object* obj) { @@ -3403,10 +3389,9 @@ class Internals { uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag; return *reinterpret_cast<T*>(addr); } - }; -} +} // namespace internal template <class T> @@ -3470,14 +3455,13 @@ void Persistent<T>::ClearWeak() { } -Arguments::Arguments(v8::Local<v8::Value> data, - v8::Local<v8::Object> holder, - v8::Local<v8::Function> callee, - bool is_construct_call, - void** values, int length) - : data_(data), holder_(holder), callee_(callee), - is_construct_call_(is_construct_call), - values_(values), length_(length) { } +Arguments::Arguments(internal::Object** implicit_args, + internal::Object** values, int length, + bool is_construct_call) + : implicit_args_(implicit_args), + values_(values), + length_(length), + is_construct_call_(is_construct_call) { } Local<Value> Arguments::operator[](int i) const { @@ -3487,7 +3471,8 @@ Local<Value> Arguments::operator[](int i) const { Local<Function> Arguments::Callee() const { - return callee_; + return Local<Function>(reinterpret_cast<Function*>( + &implicit_args_[kCalleeIndex])); } @@ -3497,12 +3482,13 @@ Local<Object> Arguments::This() const { Local<Object> Arguments::Holder() const { - return holder_; + return Local<Object>(reinterpret_cast<Object*>( + &implicit_args_[kHolderIndex])); } Local<Value> Arguments::Data() const { - return data_; + return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex])); } @@ -3565,7 +3551,7 @@ Local<Value> Object::UncheckedGetInternalField(int index) { // If the object is a plain JSObject, which is the common case, // we know where to find the internal fields and can return the // value directly. - int offset = I::kJSObjectHeaderSize + (sizeof(void*) * index); + int offset = I::kJSObjectHeaderSize + (internal::kPointerSize * index); O* value = I::ReadField<O*>(obj, offset); O** result = HandleScope::CreateHandle(value); return Local<Value>(reinterpret_cast<Value*>(result)); @@ -3601,7 +3587,7 @@ void* Object::GetPointerFromInternalField(int index) { // If the object is a plain JSObject, which is the common case, // we know where to find the internal fields and can return the // value directly. - int offset = I::kJSObjectHeaderSize + (sizeof(void*) * index); + int offset = I::kJSObjectHeaderSize + (internal::kPointerSize * index); O* value = I::ReadField<O*>(obj, offset); return I::GetExternalPointer(value); } diff --git a/include/v8stdint.h b/include/v8stdint.h new file mode 100644 index 00000000..50b4f29a --- /dev/null +++ b/include/v8stdint.h @@ -0,0 +1,53 @@ +// Copyright 2010 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Load definitions of standard types. + +#ifndef V8STDINT_H_ +#define V8STDINT_H_ + +#include <stdio.h> + +#if defined(_WIN32) && !defined(__MINGW32__) + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; // NOLINT +typedef unsigned short uint16_t; // NOLINT +typedef int int32_t; +typedef unsigned int uint32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +// intptr_t and friends are defined in crtdefs.h through stdio.h. + +#else + +#include <stdint.h> + +#endif + +#endif // V8STDINT_H_ |