Api inlining. Made some core functionality available in the api and

made inline versions of some hot functions.  Changed api to use
internal Object pointers rather than void pointers.

Speeds up getElementById by ~7%.
Review URL: http://codereview.chromium.org/173348

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2761 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a29d4e67
...@@ -105,6 +105,9 @@ LIBRARY_FLAGS = { ...@@ -105,6 +105,9 @@ LIBRARY_FLAGS = {
'arch:x64' : { 'arch:x64' : {
'CPPDEFINES': ['V8_NATIVE_REGEXP'] 'CPPDEFINES': ['V8_NATIVE_REGEXP']
} }
},
'mode:debug': {
'CPPDEFINES': ['V8_ENABLE_CHECKS']
} }
}, },
'gcc': { 'gcc': {
......
This diff is collapsed.
This diff is collapsed.
...@@ -338,7 +338,7 @@ class HandleScopeImplementer { ...@@ -338,7 +338,7 @@ class HandleScopeImplementer {
static char* Iterate(v8::internal::ObjectVisitor* v, char* data); static char* Iterate(v8::internal::ObjectVisitor* v, char* data);
inline void** GetSpareOrNewBlock(); inline internal::Object** GetSpareOrNewBlock();
inline void DeleteExtensions(int extensions); inline void DeleteExtensions(int extensions);
inline void IncrementCallDepth() {call_depth++;} inline void IncrementCallDepth() {call_depth++;}
...@@ -356,13 +356,13 @@ class HandleScopeImplementer { ...@@ -356,13 +356,13 @@ class HandleScopeImplementer {
inline Handle<Object> RestoreContext(); inline Handle<Object> RestoreContext();
inline bool HasSavedContexts(); inline bool HasSavedContexts();
inline List<void**>* Blocks() { return &blocks; } inline List<internal::Object**>* Blocks() { return &blocks; }
inline bool IgnoreOutOfMemory() { return ignore_out_of_memory; } inline bool IgnoreOutOfMemory() { return ignore_out_of_memory; }
inline void SetIgnoreOutOfMemory(bool value) { ignore_out_of_memory = value; } inline void SetIgnoreOutOfMemory(bool value) { ignore_out_of_memory = value; }
private: private:
List<void**> blocks; List<internal::Object**> blocks;
Object** spare; Object** spare;
int call_depth; int call_depth;
// Used as a stack to keep track of entered contexts. // Used as a stack to keep track of entered contexts.
...@@ -374,7 +374,7 @@ class HandleScopeImplementer { ...@@ -374,7 +374,7 @@ class HandleScopeImplementer {
v8::ImplementationUtilities::HandleScopeData handle_scope_data_; v8::ImplementationUtilities::HandleScopeData handle_scope_data_;
static void Iterate(ObjectVisitor* v, static void Iterate(ObjectVisitor* v,
List<void**>* blocks, List<internal::Object**>* blocks,
v8::ImplementationUtilities::HandleScopeData* handle_data); v8::ImplementationUtilities::HandleScopeData* handle_data);
char* RestoreThreadHelper(char* from); char* RestoreThreadHelper(char* from);
char* ArchiveThreadHelper(char* to); char* ArchiveThreadHelper(char* to);
...@@ -420,10 +420,10 @@ Handle<Object> HandleScopeImplementer::LastEnteredContext() { ...@@ -420,10 +420,10 @@ Handle<Object> HandleScopeImplementer::LastEnteredContext() {
// If there's a spare block, use it for growing the current scope. // If there's a spare block, use it for growing the current scope.
void** HandleScopeImplementer::GetSpareOrNewBlock() { internal::Object** HandleScopeImplementer::GetSpareOrNewBlock() {
void** block = (spare != NULL) ? internal::Object** block = (spare != NULL) ?
reinterpret_cast<void**>(spare) : spare :
NewArray<void*>(kHandleBlockSize); NewArray<internal::Object*>(kHandleBlockSize);
spare = NULL; spare = NULL;
return block; return block;
} }
...@@ -435,18 +435,18 @@ void HandleScopeImplementer::DeleteExtensions(int extensions) { ...@@ -435,18 +435,18 @@ void HandleScopeImplementer::DeleteExtensions(int extensions) {
spare = NULL; spare = NULL;
} }
for (int i = extensions; i > 1; --i) { for (int i = extensions; i > 1; --i) {
void** block = blocks.RemoveLast(); internal::Object** block = blocks.RemoveLast();
#ifdef DEBUG #ifdef DEBUG
v8::ImplementationUtilities::ZapHandleRange(block, v8::ImplementationUtilities::ZapHandleRange(block,
&block[kHandleBlockSize]); &block[kHandleBlockSize]);
#endif #endif
DeleteArray(block); DeleteArray(block);
} }
spare = reinterpret_cast<Object**>(blocks.RemoveLast()); spare = blocks.RemoveLast();
#ifdef DEBUG #ifdef DEBUG
v8::ImplementationUtilities::ZapHandleRange( v8::ImplementationUtilities::ZapHandleRange(
reinterpret_cast<void**>(spare), spare,
reinterpret_cast<void**>(&spare[kHandleBlockSize])); &spare[kHandleBlockSize]);
#endif #endif
} }
......
...@@ -60,7 +60,7 @@ class ImplementationUtilities { ...@@ -60,7 +60,7 @@ class ImplementationUtilities {
static HandleScopeData* CurrentHandleScope(); static HandleScopeData* CurrentHandleScope();
#ifdef DEBUG #ifdef DEBUG
static void ZapHandleRange(void** begin, void** end); static void ZapHandleRange(internal::Object** begin, internal::Object** end);
#endif #endif
}; };
......
...@@ -134,17 +134,6 @@ const intptr_t kObjectAlignmentMask = kObjectAlignment - 1; ...@@ -134,17 +134,6 @@ const intptr_t kObjectAlignmentMask = kObjectAlignment - 1;
const intptr_t kPointerAlignment = (1 << kPointerSizeLog2); const intptr_t kPointerAlignment = (1 << kPointerSizeLog2);
const intptr_t kPointerAlignmentMask = kPointerAlignment - 1; const intptr_t kPointerAlignmentMask = kPointerAlignment - 1;
// Tag information for HeapObject.
const int kHeapObjectTag = 1;
const int kHeapObjectTagSize = 2;
const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
// Tag information for Smi.
const int kSmiTag = 0;
const int kSmiTagSize = 1;
const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
// Tag information for Failure. // Tag information for Failure.
const int kFailureTag = 3; const int kFailureTag = 3;
...@@ -429,9 +418,6 @@ enum StateTag { ...@@ -429,9 +418,6 @@ enum StateTag {
#define HAS_FAILURE_TAG(value) \ #define HAS_FAILURE_TAG(value) \
((reinterpret_cast<intptr_t>(value) & kFailureTagMask) == kFailureTag) ((reinterpret_cast<intptr_t>(value) & kFailureTagMask) == kFailureTag)
#define HAS_HEAP_OBJECT_TAG(value) \
((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == kHeapObjectTag)
// OBJECT_SIZE_ALIGN returns the value aligned HeapObject size // OBJECT_SIZE_ALIGN returns the value aligned HeapObject size
#define OBJECT_SIZE_ALIGN(value) \ #define OBJECT_SIZE_ALIGN(value) \
(((value) + kObjectAlignmentMask) & ~kObjectAlignmentMask) (((value) + kObjectAlignmentMask) & ~kObjectAlignmentMask)
......
...@@ -53,8 +53,8 @@ int HandleScope::NumberOfHandles() { ...@@ -53,8 +53,8 @@ int HandleScope::NumberOfHandles() {
} }
void** HandleScope::Extend() { Object** HandleScope::Extend() {
void** result = current_.next; Object** result = current_.next;
ASSERT(result == current_.limit); ASSERT(result == current_.limit);
// Make sure there's at least one scope on the stack and that the // Make sure there's at least one scope on the stack and that the
...@@ -68,7 +68,7 @@ void** HandleScope::Extend() { ...@@ -68,7 +68,7 @@ void** HandleScope::Extend() {
// If there's more room in the last block, we use that. This is used // If there's more room in the last block, we use that. This is used
// for fast creation of scopes after scope barriers. // for fast creation of scopes after scope barriers.
if (!impl->Blocks()->is_empty()) { if (!impl->Blocks()->is_empty()) {
void** limit = &impl->Blocks()->last()[kHandleBlockSize]; Object** limit = &impl->Blocks()->last()[kHandleBlockSize];
if (current_.limit != limit) { if (current_.limit != limit) {
current_.limit = limit; current_.limit = limit;
} }
...@@ -96,10 +96,10 @@ void HandleScope::DeleteExtensions() { ...@@ -96,10 +96,10 @@ void HandleScope::DeleteExtensions() {
} }
void HandleScope::ZapRange(void** start, void** end) { void HandleScope::ZapRange(Object** start, Object** end) {
if (start == NULL) return; if (start == NULL) return;
for (void** p = start; p < end; p++) { for (Object** p = start; p < end; p++) {
*p = reinterpret_cast<void*>(v8::internal::kHandleZapValue); *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue;
} }
} }
......
...@@ -121,7 +121,7 @@ class HandleScope { ...@@ -121,7 +121,7 @@ class HandleScope {
// Creates a new handle with the given value. // Creates a new handle with the given value.
template <typename T> template <typename T>
static inline T** CreateHandle(T* value) { static inline T** CreateHandle(T* value) {
void** cur = current_.next; internal::Object** cur = current_.next;
if (cur == current_.limit) cur = Extend(); if (cur == current_.limit) cur = Extend();
// Update the current next field, set the value in the created // Update the current next field, set the value in the created
// handle, and return the result. // handle, and return the result.
...@@ -164,13 +164,13 @@ class HandleScope { ...@@ -164,13 +164,13 @@ class HandleScope {
} }
// Extend the handle scope making room for more handles. // Extend the handle scope making room for more handles.
static void** Extend(); static internal::Object** Extend();
// Deallocates any extensions used by the current scope. // Deallocates any extensions used by the current scope.
static void DeleteExtensions(); static void DeleteExtensions();
// Zaps the handles in the half-open interval [start, end). // Zaps the handles in the half-open interval [start, end).
static void ZapRange(void** start, void** end); static void ZapRange(internal::Object** start, internal::Object** end);
friend class v8::HandleScope; friend class v8::HandleScope;
friend class v8::ImplementationUtilities; friend class v8::ImplementationUtilities;
......
...@@ -2983,7 +2983,7 @@ bool Heap::LookupSymbolIfExists(String* string, String** symbol) { ...@@ -2983,7 +2983,7 @@ bool Heap::LookupSymbolIfExists(String* string, String** symbol) {
#ifdef DEBUG #ifdef DEBUG
void Heap::ZapFromSpace() { void Heap::ZapFromSpace() {
ASSERT(HAS_HEAP_OBJECT_TAG(kFromSpaceZapValue)); ASSERT(reinterpret_cast<Object*>(kFromSpaceZapValue)->IsHeapObject());
for (Address a = new_space_.FromSpaceLow(); for (Address a = new_space_.FromSpaceLow();
a < new_space_.FromSpaceHigh(); a < new_space_.FromSpaceHigh();
a += kPointerSize) { a += kPointerSize) {
......
...@@ -131,7 +131,7 @@ bool Object::IsSmi() { ...@@ -131,7 +131,7 @@ bool Object::IsSmi() {
bool Object::IsHeapObject() { bool Object::IsHeapObject() {
return HAS_HEAP_OBJECT_TAG(this); return Internals::HasHeapObjectTag(this);
} }
...@@ -300,6 +300,10 @@ uint32_t StringShape::full_representation_tag() { ...@@ -300,6 +300,10 @@ uint32_t StringShape::full_representation_tag() {
} }
STATIC_CHECK((kStringRepresentationMask | kStringEncodingMask) ==
Internals::kFullStringRepresentationMask);
uint32_t StringShape::size_tag() { uint32_t StringShape::size_tag() {
return (type_ & kStringSizeMask); return (type_ & kStringSizeMask);
} }
...@@ -325,6 +329,10 @@ bool StringShape::IsExternalTwoByte() { ...@@ -325,6 +329,10 @@ bool StringShape::IsExternalTwoByte() {
} }
STATIC_CHECK((kExternalStringTag | kTwoByteStringTag) ==
Internals::kExternalTwoByteRepresentationTag);
uc32 FlatStringReader::Get(int index) { uc32 FlatStringReader::Get(int index) {
ASSERT(0 <= index && index <= length_); ASSERT(0 <= index && index <= length_);
if (is_ascii_) { if (is_ascii_) {
...@@ -730,7 +738,7 @@ Object** HeapObject::RawField(HeapObject* obj, int byte_offset) { ...@@ -730,7 +738,7 @@ Object** HeapObject::RawField(HeapObject* obj, int byte_offset) {
int Smi::value() { int Smi::value() {
return static_cast<int>(reinterpret_cast<intptr_t>(this)) >> kSmiTagSize; return Internals::SmiValue(this);
} }
......
...@@ -1234,6 +1234,8 @@ class HeapObject: public Object { ...@@ -1234,6 +1234,8 @@ class HeapObject: public Object {
static const int kMapOffset = Object::kHeaderSize; static const int kMapOffset = Object::kHeaderSize;
static const int kHeaderSize = kMapOffset + kPointerSize; static const int kHeaderSize = kMapOffset + kPointerSize;
STATIC_CHECK(kMapOffset == Internals::kHeapObjectMapOffset);
protected: protected:
// helpers for calling an ObjectVisitor to iterate over pointers in the // helpers for calling an ObjectVisitor to iterate over pointers in the
// half-open range [start, end) specified as integer offsets // half-open range [start, end) specified as integer offsets
...@@ -1664,6 +1666,8 @@ class JSObject: public HeapObject { ...@@ -1664,6 +1666,8 @@ class JSObject: public HeapObject {
static const int kElementsOffset = kPropertiesOffset + kPointerSize; static const int kElementsOffset = kPropertiesOffset + kPointerSize;
static const int kHeaderSize = kElementsOffset + kPointerSize; static const int kHeaderSize = kElementsOffset + kPointerSize;
STATIC_CHECK(kHeaderSize == Internals::kJSObjectHeaderSize);
Object* GetElementWithInterceptor(JSObject* receiver, uint32_t index); Object* GetElementWithInterceptor(JSObject* receiver, uint32_t index);
private: private:
...@@ -2897,6 +2901,8 @@ class Map: public HeapObject { ...@@ -2897,6 +2901,8 @@ class Map: public HeapObject {
static const int kBitFieldOffset = kInstanceAttributesOffset + 2; static const int kBitFieldOffset = kInstanceAttributesOffset + 2;
static const int kBitField2Offset = kInstanceAttributesOffset + 3; static const int kBitField2Offset = kInstanceAttributesOffset + 3;
STATIC_CHECK(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset);
// Bit positions for bit field. // Bit positions for bit field.
static const int kUnused = 0; // To be used for marking recently used maps. static const int kUnused = 0; // To be used for marking recently used maps.
static const int kHasNonInstancePrototype = 1; static const int kHasNonInstancePrototype = 1;
...@@ -4128,6 +4134,8 @@ class ExternalString: public String { ...@@ -4128,6 +4134,8 @@ class ExternalString: public String {
static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize); static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize);
static const int kSize = kResourceOffset + kPointerSize; static const int kSize = kResourceOffset + kPointerSize;
STATIC_CHECK(kResourceOffset == Internals::kStringResourceOffset);
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString); DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString);
}; };
...@@ -4341,6 +4349,8 @@ class Proxy: public HeapObject { ...@@ -4341,6 +4349,8 @@ class Proxy: public HeapObject {
static const int kProxyOffset = HeapObject::kHeaderSize; static const int kProxyOffset = HeapObject::kHeaderSize;
static const int kSize = kProxyOffset + kPointerSize; static const int kSize = kProxyOffset + kPointerSize;
STATIC_CHECK(kProxyOffset == Internals::kProxyProxyOffset);
private: private:
DISALLOW_IMPLICIT_CONSTRUCTORS(Proxy); DISALLOW_IMPLICIT_CONSTRUCTORS(Proxy);
}; };
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
'DEBUG', 'DEBUG',
'_DEBUG', '_DEBUG',
'ENABLE_DISASSEMBLER', 'ENABLE_DISASSEMBLER',
'V8_ENABLE_CHECKS'
], ],
'msvs_settings': { 'msvs_settings': {
'VCCLCompilerTool': { 'VCCLCompilerTool': {
......
...@@ -1394,6 +1394,7 @@ ...@@ -1394,6 +1394,7 @@
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
"$(GCC_PREPROCESSOR_DEFINITIONS)", "$(GCC_PREPROCESSOR_DEFINITIONS)",
DEBUG, DEBUG,
V8_ENABLE_CHECKS,
); );
GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_TREAT_WARNINGS_AS_ERRORS = YES;
...@@ -1457,6 +1458,7 @@ ...@@ -1457,6 +1458,7 @@
V8_TARGET_ARCH_IA32, V8_TARGET_ARCH_IA32,
V8_NATIVE_REGEXP, V8_NATIVE_REGEXP,
DEBUG, DEBUG,
V8_ENABLE_CHECKS,
); );
HEADER_SEARCH_PATHS = ../src; HEADER_SEARCH_PATHS = ../src;
PRODUCT_NAME = v8_shell; PRODUCT_NAME = v8_shell;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
PreprocessorDefinitions="DEBUG;_DEBUG;ENABLE_DISASSEMBLER" PreprocessorDefinitions="DEBUG;_DEBUG;ENABLE_DISASSEMBLER;V8_ENABLE_CHECKS"
RuntimeLibrary="1" RuntimeLibrary="1"
/> />
<Tool <Tool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment