Version 1.2.5.
Fixed bug in initial boundary check for Boyer-Moore text search (issue 349).
Fixed compilation issues with MinGW and gcc 4.3+ and added support for armv7 and cortex-a8 architectures. Patches by Lei Zhang and Craig Schlenter.
Added a script cache to the debugger.
Optimized compilation performance by improving internal data structures and avoiding expensive property load optimizations for code that's infrequently executed.
Exposed the calling JavaScript context through the static API function Context::GetCalling().
git-svn-id: http://v8.googlecode.com/svn/trunk@2050 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/objects.h b/src/objects.h
index 2619c89..6bdddeb 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1,4 +1,4 @@
-// Copyright 2006-2008 the V8 project authors. All rights reserved.
+// Copyright 2006-2009 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:
@@ -50,7 +50,6 @@
// - JSBuiltinsObject
// - JSGlobalProxy
// - JSValue
-// - Script
// - Array
// - ByteArray
// - FixedArray
@@ -83,8 +82,10 @@
// - AccessCheckInfo
// - InterceptorInfo
// - CallHandlerInfo
-// - FunctionTemplateInfo
-// - ObjectTemplateInfo
+// - TemplateInfo
+// - FunctionTemplateInfo
+// - ObjectTemplateInfo
+// - Script
// - SignatureInfo
// - TypeSwitchInfo
// - DebugInfo
@@ -108,7 +109,8 @@
// a non-existent property.
};
-namespace v8 { namespace internal {
+namespace v8 {
+namespace internal {
// PropertyDetails captures type and attributes for a property.
@@ -295,12 +297,14 @@
// Since string types are not consecutive, this macro is used to
// iterate over them.
#define STRING_TYPE_LIST(V) \
- V(SHORT_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, short_symbol) \
- V(MEDIUM_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, medium_symbol) \
- V(LONG_SYMBOL_TYPE, SeqTwoByteString::kHeaderSize, long_symbol) \
- V(SHORT_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, short_ascii_symbol) \
- V(MEDIUM_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, medium_ascii_symbol)\
- V(LONG_ASCII_SYMBOL_TYPE, SeqAsciiString::kHeaderSize, long_ascii_symbol) \
+ V(SHORT_SYMBOL_TYPE, SeqTwoByteString::kAlignedSize, short_symbol) \
+ V(MEDIUM_SYMBOL_TYPE, SeqTwoByteString::kAlignedSize, medium_symbol) \
+ V(LONG_SYMBOL_TYPE, SeqTwoByteString::kAlignedSize, long_symbol) \
+ V(SHORT_ASCII_SYMBOL_TYPE, SeqAsciiString::kAlignedSize, short_ascii_symbol) \
+ V(MEDIUM_ASCII_SYMBOL_TYPE, \
+ SeqAsciiString::kAlignedSize, \
+ medium_ascii_symbol) \
+ V(LONG_ASCII_SYMBOL_TYPE, SeqAsciiString::kAlignedSize, long_ascii_symbol) \
V(SHORT_CONS_SYMBOL_TYPE, ConsString::kSize, short_cons_symbol) \
V(MEDIUM_CONS_SYMBOL_TYPE, ConsString::kSize, medium_cons_symbol) \
V(LONG_CONS_SYMBOL_TYPE, ConsString::kSize, long_cons_symbol) \
@@ -337,12 +341,14 @@
V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE, \
ExternalAsciiString::kSize, \
long_external_ascii_symbol) \
- V(SHORT_STRING_TYPE, SeqTwoByteString::kHeaderSize, short_string) \
- V(MEDIUM_STRING_TYPE, SeqTwoByteString::kHeaderSize, medium_string) \
- V(LONG_STRING_TYPE, SeqTwoByteString::kHeaderSize, long_string) \
- V(SHORT_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, short_ascii_string) \
- V(MEDIUM_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, medium_ascii_string)\
- V(LONG_ASCII_STRING_TYPE, SeqAsciiString::kHeaderSize, long_ascii_string) \
+ V(SHORT_STRING_TYPE, SeqTwoByteString::kAlignedSize, short_string) \
+ V(MEDIUM_STRING_TYPE, SeqTwoByteString::kAlignedSize, medium_string) \
+ V(LONG_STRING_TYPE, SeqTwoByteString::kAlignedSize, long_string) \
+ V(SHORT_ASCII_STRING_TYPE, SeqAsciiString::kAlignedSize, short_ascii_string) \
+ V(MEDIUM_ASCII_STRING_TYPE, \
+ SeqAsciiString::kAlignedSize, \
+ medium_ascii_string) \
+ V(LONG_ASCII_STRING_TYPE, SeqAsciiString::kAlignedSize, long_ascii_string) \
V(SHORT_CONS_STRING_TYPE, ConsString::kSize, short_cons_string) \
V(MEDIUM_CONS_STRING_TYPE, ConsString::kSize, medium_cons_string) \
V(LONG_CONS_STRING_TYPE, ConsString::kSize, long_cons_string) \
@@ -771,8 +777,10 @@
// Smi represents integer Numbers that can be stored in 31 bits.
+// TODO(X64) Increase to 53 bits?
// Smis are immediate which means they are NOT allocated in the heap.
// The this pointer has the following format: [31 bit signed int] 0
+// TODO(X64): 31 bits signed int sign-extended to 63 bits.
// Smi stands for small integer.
class Smi: public Object {
public:
@@ -1550,6 +1558,7 @@
// Layout descriptor.
static const int kLengthOffset = HeapObject::kHeaderSize;
static const int kHeaderSize = kLengthOffset + kIntSize;
+ static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(Array);
@@ -1596,6 +1605,9 @@
// Casting.
static inline FixedArray* cast(Object* obj);
+ // Align data at kPointerSize, even if Array.kHeaderSize isn't aligned.
+ static const int kHeaderSize = POINTER_SIZE_ALIGN(Array::kHeaderSize);
+
// Dispatched behavior.
int FixedArraySize() { return SizeFor(length()); }
void FixedArrayIterateBody(ObjectVisitor* v);
@@ -2147,7 +2159,7 @@
inline int get_int(int index);
static int SizeFor(int length) {
- return kHeaderSize + OBJECT_SIZE_ALIGN(length);
+ return OBJECT_SIZE_ALIGN(kHeaderSize + length);
}
// We use byte arrays for free blocks in the heap. Given a desired size in
// bytes that is a multiple of the word size and big enough to hold a byte
@@ -2241,9 +2253,10 @@
// [flags]: Access to specific code flags.
inline Kind kind();
- inline InlineCacheState ic_state(); // only valid for IC stubs
- inline PropertyType type(); // only valid for monomorphic IC stubs
- inline int arguments_count(); // only valid for call IC stubs
+ inline InlineCacheState ic_state(); // Only valid for IC stubs.
+ inline InLoopFlag ic_in_loop(); // Only valid for IC stubs..
+ inline PropertyType type(); // Only valid for monomorphic IC stubs.
+ inline int arguments_count(); // Only valid for call IC stubs.
// Testers for IC stub kinds.
inline bool is_inline_cache_stub();
@@ -2265,16 +2278,20 @@
// Flags operations.
static inline Flags ComputeFlags(Kind kind,
+ InLoopFlag in_loop = NOT_IN_LOOP,
InlineCacheState ic_state = UNINITIALIZED,
PropertyType type = NORMAL,
int argc = -1);
- static inline Flags ComputeMonomorphicFlags(Kind kind,
- PropertyType type,
- int argc = -1);
+ static inline Flags ComputeMonomorphicFlags(
+ Kind kind,
+ PropertyType type,
+ InLoopFlag in_loop = NOT_IN_LOOP,
+ int argc = -1);
static inline Kind ExtractKindFromFlags(Flags flags);
static inline InlineCacheState ExtractICStateFromFlags(Flags flags);
+ static inline InLoopFlag ExtractICInLoopFromFlags(Flags flags);
static inline PropertyType ExtractTypeFromFlags(Flags flags);
static inline int ExtractArgumentsCountFromFlags(Flags flags);
static inline Flags RemoveTypeFromFlags(Flags flags);
@@ -2344,6 +2361,9 @@
void CodePrint();
void CodeVerify();
#endif
+ // Code entry points are aligned to 32 bytes.
+ static const int kCodeAlignment = 32;
+ static const int kCodeAlignmentMask = kCodeAlignment - 1;
// Layout description.
static const int kInstructionSizeOffset = HeapObject::kHeaderSize;
@@ -2351,14 +2371,11 @@
static const int kSInfoSizeOffset = kRelocationSizeOffset + kIntSize;
static const int kFlagsOffset = kSInfoSizeOffset + kIntSize;
static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize;
- // Add filler objects to align the instruction start following right after
+ // Add padding to align the instruction start following right after
// the Code object header.
- static const int kFiller6Offset = kKindSpecificFlagsOffset + kIntSize;
- static const int kFiller7Offset = kFiller6Offset + kIntSize;
- static const int kHeaderSize = kFiller7Offset + kIntSize;
-
- // Code entry points are aligned to 32 bytes.
- static const int kCodeAlignment = 32;
+ static const int kHeaderSize =
+ (kKindSpecificFlagsOffset + kIntSize + kCodeAlignmentMask) &
+ ~kCodeAlignmentMask;
// Byte offsets within kKindSpecificFlagsOffset.
static const int kICFlagOffset = kKindSpecificFlagsOffset + 0;
@@ -2366,14 +2383,19 @@
// Flags layout.
static const int kFlagsICStateShift = 0;
- static const int kFlagsKindShift = 3;
- static const int kFlagsTypeShift = 6;
- static const int kFlagsArgumentsCountShift = 9;
+ static const int kFlagsICInLoopShift = 3;
+ static const int kFlagsKindShift = 4;
+ static const int kFlagsTypeShift = 7;
+ static const int kFlagsArgumentsCountShift = 10;
- static const int kFlagsICStateMask = 0x00000007; // 000000111
- static const int kFlagsKindMask = 0x00000038; // 000111000
- static const int kFlagsTypeMask = 0x000001C0; // 111000000
- static const int kFlagsArgumentsCountMask = 0xFFFFFE00;
+ static const int kFlagsICStateMask = 0x00000007; // 0000000111
+ static const int kFlagsICInLoopMask = 0x00000008; // 0000001000
+ static const int kFlagsKindMask = 0x00000070; // 0001110000
+ static const int kFlagsTypeMask = 0x00000380; // 1110000000
+ static const int kFlagsArgumentsCountMask = 0xFFFFFC00;
+
+ static const int kFlagsNotUsedInLookup =
+ (kFlagsICInLoopMask | kFlagsTypeMask);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
@@ -2567,7 +2589,7 @@
static const int kInstanceDescriptorsOffset =
kConstructorOffset + kPointerSize;
static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize;
- static const int kSize = kCodeCacheOffset + kIntSize;
+ static const int kSize = kCodeCacheOffset + kPointerSize;
// Byte offsets within kInstanceSizesOffset.
static const int kInstanceSizeOffset = kInstanceSizesOffset + 0;
@@ -2776,21 +2798,23 @@
static const int kDontAdaptArgumentsSentinel = -1;
// Layout description.
+ // (An even number of integers has a size that is a multiple of a pointer.)
static const int kNameOffset = HeapObject::kHeaderSize;
static const int kCodeOffset = kNameOffset + kPointerSize;
static const int kLengthOffset = kCodeOffset + kPointerSize;
static const int kFormalParameterCountOffset = kLengthOffset + kIntSize;
static const int kExpectedNofPropertiesOffset =
kFormalParameterCountOffset + kIntSize;
- static const int kInstanceClassNameOffset =
+ static const int kStartPositionAndTypeOffset =
kExpectedNofPropertiesOffset + kIntSize;
+ static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize;
+ static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize;
+ static const int kInstanceClassNameOffset =
+ kFunctionTokenPositionOffset + kIntSize;
static const int kExternalReferenceDataOffset =
kInstanceClassNameOffset + kPointerSize;
static const int kScriptOffset = kExternalReferenceDataOffset + kPointerSize;
- static const int kStartPositionAndTypeOffset = kScriptOffset + kPointerSize;
- static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize;
- static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize;
- static const int kDebugInfoOffset = kFunctionTokenPositionOffset + kIntSize;
+ static const int kDebugInfoOffset = kScriptOffset + kPointerSize;
static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize;
static const int kSize = kInferredNameOffset + kPointerSize;
@@ -3100,7 +3124,7 @@
#endif
static const int kDataOffset = JSObject::kHeaderSize;
- static const int kSize = kDataOffset + kIntSize;
+ static const int kSize = kDataOffset + kPointerSize;
// Indices in the data array.
static const int kTagIndex = 0;
@@ -3365,6 +3389,7 @@
// Layout description.
static const int kLengthOffset = HeapObject::kHeaderSize;
static const int kSize = kLengthOffset + kIntSize;
+ // Notice: kSize is not pointer-size aligned if pointers are 64-bit.
// Limits on sizes of different types of strings.
static const int kMaxShortStringSize = 63;
@@ -3513,11 +3538,12 @@
// Computes the size for an AsciiString instance of a given length.
static int SizeFor(int length) {
- return kHeaderSize + OBJECT_SIZE_ALIGN(length * kCharSize);
+ return OBJECT_SIZE_ALIGN(kHeaderSize + length * kCharSize);
}
// Layout description.
static const int kHeaderSize = String::kSize;
+ static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize);
// Support for StringInputBuffer.
inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
@@ -3558,11 +3584,12 @@
// Computes the size for a TwoByteString instance of a given length.
static int SizeFor(int length) {
- return kHeaderSize + OBJECT_SIZE_ALIGN(length * kShortSize);
+ return OBJECT_SIZE_ALIGN(kHeaderSize + length * kShortSize);
}
// Layout description.
static const int kHeaderSize = String::kSize;
+ static const int kAlignedSize = POINTER_SIZE_ALIGN(kHeaderSize);
// Support for StringInputBuffer.
inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
@@ -3612,7 +3639,7 @@
void ConsStringIterateBody(ObjectVisitor* v);
// Layout description.
- static const int kFirstOffset = String::kSize;
+ static const int kFirstOffset = POINTER_SIZE_ALIGN(String::kSize);
static const int kSecondOffset = kFirstOffset + kPointerSize;
static const int kSize = kSecondOffset + kPointerSize;
@@ -3656,9 +3683,18 @@
void SlicedStringIterateBody(ObjectVisitor* v);
// Layout description
+#if V8_HOST_ARCH_64_BIT
+ // Optimizations expect buffer to be located at same offset as a ConsString's
+ // first substring. In 64 bit mode we have room for the size before the
+ // buffer.
+ static const int kStartOffset = String::kSize;
+ static const int kBufferOffset = kStartOffset + kIntSize;
+ static const int kSize = kBufferOffset + kPointerSize;
+#else
static const int kBufferOffset = String::kSize;
static const int kStartOffset = kBufferOffset + kPointerSize;
static const int kSize = kStartOffset + kIntSize;
+#endif
// Support for StringInputBuffer.
inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer,
@@ -3688,7 +3724,7 @@
static inline ExternalString* cast(Object* obj);
// Layout description.
- static const int kResourceOffset = String::kSize;
+ static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize);
static const int kSize = kResourceOffset + kPointerSize;
private:
@@ -4148,7 +4184,7 @@
static const int kConstructorOffset = TemplateInfo::kHeaderSize;
static const int kInternalFieldCountOffset =
kConstructorOffset + kPointerSize;
- static const int kSize = kInternalFieldCountOffset + kHeaderSize;
+ static const int kSize = kInternalFieldCountOffset + kPointerSize;
};