Revert "Handlifying clients of StringTable, step 1."
This reverts commit r20772. TBR=jarin@chromium.org Review URL: https://codereview.chromium.org/239273002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20775 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
4cbbf0ae83
commit
cc5c454573
@ -37,16 +37,6 @@ Handle<Box> Factory::NewBox(Handle<Object> value) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Oddball> Factory::NewOddball(Handle<Map> map,
|
||||
const char* to_string,
|
||||
Handle<Object> to_number,
|
||||
byte kind) {
|
||||
Handle<Oddball> oddball = New<Oddball>(map, OLD_POINTER_SPACE);
|
||||
Oddball::Initialize(isolate(), oddball, to_string, to_number, kind);
|
||||
return oddball;
|
||||
}
|
||||
|
||||
|
||||
Handle<FixedArray> Factory::NewFixedArray(int size, PretenureFlag pretenure) {
|
||||
ASSERT(0 <= size);
|
||||
CALL_HEAP_FUNCTION(
|
||||
|
@ -14,11 +14,6 @@ namespace internal {
|
||||
|
||||
class Factory V8_FINAL {
|
||||
public:
|
||||
Handle<Oddball> NewOddball(Handle<Map> map,
|
||||
const char* to_string,
|
||||
Handle<Object> to_number,
|
||||
byte kind);
|
||||
|
||||
// Allocates a fixed array initialized with undefined values.
|
||||
Handle<FixedArray> NewFixedArray(
|
||||
int size,
|
||||
|
228
src/heap.cc
228
src/heap.cc
@ -2759,6 +2759,18 @@ MaybeObject* Heap::AllocateAllocationSite() {
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* Heap::CreateOddball(Map* map,
|
||||
const char* to_string,
|
||||
Object* to_number,
|
||||
byte kind) {
|
||||
Object* result;
|
||||
{ MaybeObject* maybe_result = Allocate(map, OLD_POINTER_SPACE);
|
||||
if (!maybe_result->ToObject(&result)) return maybe_result;
|
||||
}
|
||||
return Oddball::cast(result)->Initialize(this, to_string, to_number, kind);
|
||||
}
|
||||
|
||||
|
||||
bool Heap::CreateApiObjects() {
|
||||
Object* obj;
|
||||
|
||||
@ -2831,82 +2843,115 @@ void Heap::CreateFixedStubs() {
|
||||
|
||||
|
||||
bool Heap::CreateInitialObjects() {
|
||||
HandleScope scope(isolate());
|
||||
Factory* factory = isolate()->factory();
|
||||
Object* obj;
|
||||
|
||||
// The -0 value must be set before NumberFromDouble works.
|
||||
set_minus_zero_value(*factory->NewHeapNumber(-0.0, TENURED));
|
||||
{ MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_minus_zero_value(HeapNumber::cast(obj));
|
||||
ASSERT(std::signbit(minus_zero_value()->Number()) != 0);
|
||||
|
||||
set_nan_value(*factory->NewHeapNumber(OS::nan_value(), TENURED));
|
||||
set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, TENURED));
|
||||
{ MaybeObject* maybe_obj = AllocateHeapNumber(OS::nan_value(), TENURED);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_nan_value(HeapNumber::cast(obj));
|
||||
|
||||
{ MaybeObject* maybe_obj = AllocateHeapNumber(V8_INFINITY, TENURED);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_infinity_value(HeapNumber::cast(obj));
|
||||
|
||||
// The hole has not been created yet, but we want to put something
|
||||
// predictable in the gaps in the string table, so lets make that Smi zero.
|
||||
set_the_hole_value(reinterpret_cast<Oddball*>(Smi::FromInt(0)));
|
||||
|
||||
// Allocate initial string table.
|
||||
set_string_table(*StringTable::New(isolate(), kInitialStringTableSize));
|
||||
{ MaybeObject* maybe_obj =
|
||||
StringTable::Allocate(this, kInitialStringTableSize);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
// Don't use set_string_table() due to asserts.
|
||||
roots_[kStringTableRootIndex] = obj;
|
||||
|
||||
// Finish initializing oddballs after creating the string table.
|
||||
Oddball::Initialize(isolate(),
|
||||
factory->undefined_value(),
|
||||
"undefined",
|
||||
factory->nan_value(),
|
||||
Oddball::kUndefined);
|
||||
|
||||
// Initialize the null_value.
|
||||
Oddball::Initialize(isolate(),
|
||||
factory->null_value(),
|
||||
"null",
|
||||
handle(Smi::FromInt(0), isolate()),
|
||||
Oddball::kNull);
|
||||
|
||||
set_true_value(*factory->NewOddball(factory->boolean_map(),
|
||||
"true",
|
||||
handle(Smi::FromInt(1), isolate()),
|
||||
Oddball::kTrue));
|
||||
|
||||
set_false_value(*factory->NewOddball(factory->boolean_map(),
|
||||
"false",
|
||||
handle(Smi::FromInt(0), isolate()),
|
||||
Oddball::kFalse));
|
||||
|
||||
set_the_hole_value(*factory->NewOddball(factory->the_hole_map(),
|
||||
"hole",
|
||||
handle(Smi::FromInt(-1), isolate()),
|
||||
Oddball::kTheHole));
|
||||
|
||||
set_uninitialized_value(
|
||||
*factory->NewOddball(factory->uninitialized_map(),
|
||||
"uninitialized",
|
||||
handle(Smi::FromInt(-1), isolate()),
|
||||
Oddball::kUninitialized));
|
||||
|
||||
set_arguments_marker(*factory->NewOddball(factory->arguments_marker_map(),
|
||||
"arguments_marker",
|
||||
handle(Smi::FromInt(-4), isolate()),
|
||||
Oddball::kArgumentMarker));
|
||||
|
||||
set_no_interceptor_result_sentinel(
|
||||
*factory->NewOddball(factory->no_interceptor_result_sentinel_map(),
|
||||
"no_interceptor_result_sentinel",
|
||||
handle(Smi::FromInt(-2), isolate()),
|
||||
Oddball::kOther));
|
||||
|
||||
set_termination_exception(
|
||||
*factory->NewOddball(factory->termination_exception_map(),
|
||||
"termination_exception",
|
||||
handle(Smi::FromInt(-3), isolate()),
|
||||
Oddball::kOther));
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(constant_string_table); i++) {
|
||||
Handle<String> str =
|
||||
factory->InternalizeUtf8String(constant_string_table[i].contents);
|
||||
roots_[constant_string_table[i].index] = *str;
|
||||
{ MaybeObject* maybe_obj =
|
||||
undefined_value()->Initialize(this,
|
||||
"undefined",
|
||||
nan_value(),
|
||||
Oddball::kUndefined);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
|
||||
Object* obj;
|
||||
// Initialize the null_value.
|
||||
{ MaybeObject* maybe_obj = null_value()->Initialize(
|
||||
this, "null", Smi::FromInt(0), Oddball::kNull);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
|
||||
{ MaybeObject* maybe_obj = CreateOddball(boolean_map(),
|
||||
"true",
|
||||
Smi::FromInt(1),
|
||||
Oddball::kTrue);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_true_value(Oddball::cast(obj));
|
||||
|
||||
{ MaybeObject* maybe_obj = CreateOddball(boolean_map(),
|
||||
"false",
|
||||
Smi::FromInt(0),
|
||||
Oddball::kFalse);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_false_value(Oddball::cast(obj));
|
||||
|
||||
{ MaybeObject* maybe_obj = CreateOddball(the_hole_map(),
|
||||
"hole",
|
||||
Smi::FromInt(-1),
|
||||
Oddball::kTheHole);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_the_hole_value(Oddball::cast(obj));
|
||||
|
||||
{ MaybeObject* maybe_obj = CreateOddball(uninitialized_map(),
|
||||
"uninitialized",
|
||||
Smi::FromInt(-1),
|
||||
Oddball::kUninitialized);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_uninitialized_value(Oddball::cast(obj));
|
||||
|
||||
{ MaybeObject* maybe_obj = CreateOddball(arguments_marker_map(),
|
||||
"arguments_marker",
|
||||
Smi::FromInt(-4),
|
||||
Oddball::kArgumentMarker);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_arguments_marker(Oddball::cast(obj));
|
||||
|
||||
{ MaybeObject* maybe_obj = CreateOddball(no_interceptor_result_sentinel_map(),
|
||||
"no_interceptor_result_sentinel",
|
||||
Smi::FromInt(-2),
|
||||
Oddball::kOther);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_no_interceptor_result_sentinel(Oddball::cast(obj));
|
||||
|
||||
{ MaybeObject* maybe_obj = CreateOddball(termination_exception_map(),
|
||||
"termination_exception",
|
||||
Smi::FromInt(-3),
|
||||
Oddball::kOther);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_termination_exception(Oddball::cast(obj));
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(constant_string_table); i++) {
|
||||
{ MaybeObject* maybe_obj =
|
||||
InternalizeUtf8String(constant_string_table[i].contents);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
roots_[constant_string_table[i].index] = String::cast(obj);
|
||||
}
|
||||
|
||||
// Allocate the hidden string which is used to identify the hidden properties
|
||||
// in JSObjects. The hash code has a special value so that it will not match
|
||||
@ -2947,12 +2992,11 @@ bool Heap::CreateInitialObjects() {
|
||||
CreateFixedStubs();
|
||||
|
||||
// Allocate the dictionary of intrinsic function names.
|
||||
{
|
||||
Handle<NameDictionary> function_names =
|
||||
NameDictionary::New(isolate(), Runtime::kNumFunctions);
|
||||
Runtime::InitializeIntrinsicFunctionNames(isolate(), function_names);
|
||||
set_intrinsic_function_names(*function_names);
|
||||
{ MaybeObject* maybe_obj =
|
||||
NameDictionary::Allocate(this, Runtime::kNumFunctions);
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
}
|
||||
set_intrinsic_function_names(NameDictionary::cast(obj));
|
||||
|
||||
{ MaybeObject* maybe_obj = AllocateInitialNumberStringCache();
|
||||
if (!maybe_obj->ToObject(&obj)) return false;
|
||||
@ -3151,58 +3195,60 @@ Object* RegExpResultsCache::Lookup(Heap* heap,
|
||||
}
|
||||
|
||||
|
||||
void RegExpResultsCache::Enter(Isolate* isolate,
|
||||
Handle<String> key_string,
|
||||
Handle<Object> key_pattern,
|
||||
Handle<FixedArray> value_array,
|
||||
void RegExpResultsCache::Enter(Heap* heap,
|
||||
String* key_string,
|
||||
Object* key_pattern,
|
||||
FixedArray* value_array,
|
||||
ResultsCacheType type) {
|
||||
Factory* factory = isolate->factory();
|
||||
Handle<FixedArray> cache;
|
||||
FixedArray* cache;
|
||||
if (!key_string->IsInternalizedString()) return;
|
||||
if (type == STRING_SPLIT_SUBSTRINGS) {
|
||||
ASSERT(key_pattern->IsString());
|
||||
if (!key_pattern->IsInternalizedString()) return;
|
||||
cache = factory->string_split_cache();
|
||||
cache = heap->string_split_cache();
|
||||
} else {
|
||||
ASSERT(type == REGEXP_MULTIPLE_INDICES);
|
||||
ASSERT(key_pattern->IsFixedArray());
|
||||
cache = factory->regexp_multiple_cache();
|
||||
cache = heap->regexp_multiple_cache();
|
||||
}
|
||||
|
||||
uint32_t hash = key_string->Hash();
|
||||
uint32_t index = ((hash & (kRegExpResultsCacheSize - 1)) &
|
||||
~(kArrayEntriesPerCacheEntry - 1));
|
||||
if (cache->get(index + kStringOffset) == Smi::FromInt(0)) {
|
||||
cache->set(index + kStringOffset, *key_string);
|
||||
cache->set(index + kPatternOffset, *key_pattern);
|
||||
cache->set(index + kArrayOffset, *value_array);
|
||||
cache->set(index + kStringOffset, key_string);
|
||||
cache->set(index + kPatternOffset, key_pattern);
|
||||
cache->set(index + kArrayOffset, value_array);
|
||||
} else {
|
||||
uint32_t index2 =
|
||||
((index + kArrayEntriesPerCacheEntry) & (kRegExpResultsCacheSize - 1));
|
||||
if (cache->get(index2 + kStringOffset) == Smi::FromInt(0)) {
|
||||
cache->set(index2 + kStringOffset, *key_string);
|
||||
cache->set(index2 + kPatternOffset, *key_pattern);
|
||||
cache->set(index2 + kArrayOffset, *value_array);
|
||||
cache->set(index2 + kStringOffset, key_string);
|
||||
cache->set(index2 + kPatternOffset, key_pattern);
|
||||
cache->set(index2 + kArrayOffset, value_array);
|
||||
} else {
|
||||
cache->set(index2 + kStringOffset, Smi::FromInt(0));
|
||||
cache->set(index2 + kPatternOffset, Smi::FromInt(0));
|
||||
cache->set(index2 + kArrayOffset, Smi::FromInt(0));
|
||||
cache->set(index + kStringOffset, *key_string);
|
||||
cache->set(index + kPatternOffset, *key_pattern);
|
||||
cache->set(index + kArrayOffset, *value_array);
|
||||
cache->set(index + kStringOffset, key_string);
|
||||
cache->set(index + kPatternOffset, key_pattern);
|
||||
cache->set(index + kArrayOffset, value_array);
|
||||
}
|
||||
}
|
||||
// If the array is a reasonably short list of substrings, convert it into a
|
||||
// list of internalized strings.
|
||||
if (type == STRING_SPLIT_SUBSTRINGS && value_array->length() < 100) {
|
||||
for (int i = 0; i < value_array->length(); i++) {
|
||||
Handle<String> str(String::cast(value_array->get(i)), isolate);
|
||||
Handle<String> internalized_str = factory->InternalizeString(str);
|
||||
value_array->set(i, *internalized_str);
|
||||
String* str = String::cast(value_array->get(i));
|
||||
Object* internalized_str;
|
||||
MaybeObject* maybe_string = heap->InternalizeString(str);
|
||||
if (maybe_string->ToObject(&internalized_str)) {
|
||||
value_array->set(i, internalized_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Convert backing store to a copy-on-write array.
|
||||
value_array->set_map_no_write_barrier(*factory->fixed_cow_array_map());
|
||||
value_array->set_map_no_write_barrier(heap->fixed_cow_array_map());
|
||||
}
|
||||
|
||||
|
||||
@ -5926,12 +5972,16 @@ bool Heap::CreateHeapObjects() {
|
||||
|
||||
// Create initial objects
|
||||
if (!CreateInitialObjects()) return false;
|
||||
CHECK_EQ(0, gc_count_);
|
||||
|
||||
native_contexts_list_ = undefined_value();
|
||||
array_buffers_list_ = undefined_value();
|
||||
allocation_sites_list_ = undefined_value();
|
||||
weak_object_to_code_table_ = undefined_value();
|
||||
|
||||
HandleScope scope(isolate());
|
||||
Runtime::InitializeIntrinsicFunctionNames(
|
||||
isolate(), handle(intrinsic_function_names(), isolate()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
13
src/heap.h
13
src/heap.h
@ -2094,6 +2094,11 @@ class Heap {
|
||||
|
||||
void CreateFixedStubs();
|
||||
|
||||
MUST_USE_RESULT MaybeObject* CreateOddball(Map* map,
|
||||
const char* to_string,
|
||||
Object* to_number,
|
||||
byte kind);
|
||||
|
||||
// Allocate empty fixed array.
|
||||
MUST_USE_RESULT MaybeObject* AllocateEmptyFixedArray();
|
||||
|
||||
@ -2870,10 +2875,10 @@ class RegExpResultsCache {
|
||||
ResultsCacheType type);
|
||||
// Attempt to add value_array to the cache specified by type. On success,
|
||||
// value_array is turned into a COW-array.
|
||||
static void Enter(Isolate* isolate,
|
||||
Handle<String> key_string,
|
||||
Handle<Object> key_pattern,
|
||||
Handle<FixedArray> value_array,
|
||||
static void Enter(Heap* heap,
|
||||
String* key_string,
|
||||
Object* key_pattern,
|
||||
FixedArray* value_array,
|
||||
ResultsCacheType type);
|
||||
static void Clear(FixedArray* cache);
|
||||
static const int kRegExpResultsCacheSize = 0x100;
|
||||
|
@ -10096,16 +10096,20 @@ bool JSFunction::PassesFilter(const char* raw_filter) {
|
||||
}
|
||||
|
||||
|
||||
void Oddball::Initialize(Isolate* isolate,
|
||||
Handle<Oddball> oddball,
|
||||
const char* to_string,
|
||||
Handle<Object> to_number,
|
||||
byte kind) {
|
||||
Handle<String> internalized_to_string =
|
||||
isolate->factory()->InternalizeUtf8String(CStrVector(to_string));
|
||||
oddball->set_to_string(*internalized_to_string);
|
||||
oddball->set_to_number(*to_number);
|
||||
oddball->set_kind(kind);
|
||||
MaybeObject* Oddball::Initialize(Heap* heap,
|
||||
const char* to_string,
|
||||
Object* to_number,
|
||||
byte kind) {
|
||||
String* internalized_to_string;
|
||||
{ MaybeObject* maybe_string =
|
||||
heap->InternalizeUtf8String(
|
||||
CStrVector(to_string));
|
||||
if (!maybe_string->To(&internalized_to_string)) return maybe_string;
|
||||
}
|
||||
set_to_string(internalized_to_string);
|
||||
set_to_number(to_number);
|
||||
set_kind(kind);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ -14421,10 +14425,6 @@ Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
|
||||
int,
|
||||
JSObject::DeleteMode);
|
||||
|
||||
template Handle<NameDictionary>
|
||||
HashTable<NameDictionary, NameDictionaryShape, Name*>::
|
||||
New(Isolate*, int, MinimumCapacity, PretenureFlag);
|
||||
|
||||
template Handle<NameDictionary>
|
||||
HashTable<NameDictionary, NameDictionaryShape, Name*>::
|
||||
Shrink(Handle<NameDictionary>, Name* n);
|
||||
|
@ -9723,11 +9723,10 @@ class Oddball: public HeapObject {
|
||||
DECLARE_VERIFIER(Oddball)
|
||||
|
||||
// Initialize the fields.
|
||||
static void Initialize(Isolate* isolate,
|
||||
Handle<Oddball> oddball,
|
||||
const char* to_string,
|
||||
Handle<Object> to_number,
|
||||
byte kind);
|
||||
MUST_USE_RESULT MaybeObject* Initialize(Heap* heap,
|
||||
const char* to_string,
|
||||
Object* to_number,
|
||||
byte kind);
|
||||
|
||||
// Layout description.
|
||||
static const int kToStringOffset = HeapObject::kHeaderSize;
|
||||
|
@ -4730,10 +4730,10 @@ static MaybeObject* SearchRegExpMultiple(
|
||||
fixed_array->set(fixed_array->length() - 1,
|
||||
Smi::FromInt(builder.length()));
|
||||
// Cache the result and turn the FixedArray into a COW array.
|
||||
RegExpResultsCache::Enter(isolate,
|
||||
subject,
|
||||
handle(regexp->data(), isolate),
|
||||
fixed_array,
|
||||
RegExpResultsCache::Enter(isolate->heap(),
|
||||
*subject,
|
||||
regexp->data(),
|
||||
*fixed_array,
|
||||
RegExpResultsCache::REGEXP_MULTIPLE_INDICES);
|
||||
}
|
||||
return *builder.ToJSArray(result_array);
|
||||
@ -6750,10 +6750,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
|
||||
|
||||
if (limit == 0xffffffffu) {
|
||||
if (result->HasFastObjectElements()) {
|
||||
RegExpResultsCache::Enter(isolate,
|
||||
subject,
|
||||
pattern,
|
||||
elements,
|
||||
RegExpResultsCache::Enter(isolate->heap(),
|
||||
*subject,
|
||||
*pattern,
|
||||
*elements,
|
||||
RegExpResultsCache::STRING_SPLIT_SUBSTRINGS);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user