Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: src/heap.cc

Issue 239273002: Revert "Handlifying clients of StringTable, step 1." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 582310cc0df49053ee1b6e8dcec15012014fa46c..b4e6dde1d56ee5ef8cd1876d5dc58f8edb55109a 100644
--- a/src/heap.cc
+++ b/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);
+ { MaybeObject* maybe_obj =
+ undefined_value()->Initialize(this,
+ "undefined",
+ nan_value(),
+ Oddball::kUndefined);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
// 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));
+ { MaybeObject* maybe_obj = null_value()->Initialize(
+ this, "null", Smi::FromInt(0), Oddball::kNull);
+ if (!maybe_obj->ToObject(&obj)) return false;
+ }
- 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 = CreateOddball(boolean_map(),
+ "true",
+ Smi::FromInt(1),
+ Oddball::kTrue);
+ if (!maybe_obj->ToObject(&obj)) return false;
}
+ set_true_value(Oddball::cast(obj));
- Object* 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;
}
« no previous file with comments | « src/heap.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698