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