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

Unified Diff: src/heap.cc

Issue 239113002: Handlifying clients of StringTable, step 1. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review notes 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 03f68a7958e66defc2df178a02a5a7ae7b1e11f9..ebb46f3c0bd27daf5947fc7b39b52d58e9c1883c 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -2759,18 +2759,6 @@ 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;
@@ -2843,116 +2831,83 @@ void Heap::CreateFixedStubs() {
bool Heap::CreateInitialObjects() {
- Object* obj;
+ HandleScope scope(isolate());
+ Factory* factory = isolate()->factory();
// The -0 value must be set before NumberFromDouble works.
- { MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED);
- if (!maybe_obj->ToObject(&obj)) return false;
- }
- set_minus_zero_value(HeapNumber::cast(obj));
+ set_minus_zero_value(*factory->NewHeapNumber(-0.0, TENURED));
ASSERT(std::signbit(minus_zero_value()->Number()) != 0);
- { 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));
+ set_nan_value(*factory->NewHeapNumber(OS::nan_value(), TENURED));
+ set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, TENURED));
// 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.
- { 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;
+ set_string_table(*StringTable::New(isolate(), kInitialStringTableSize));
// Finish initializing oddballs after creating the string table.
- { MaybeObject* maybe_obj =
- undefined_value()->Initialize(this,
- "undefined",
- nan_value(),
- Oddball::kUndefined);
- if (!maybe_obj->ToObject(&obj)) return false;
- }
+ Oddball::Initialize(isolate(),
+ factory->undefined_value(),
+ "undefined",
+ factory->nan_value(),
+ Oddball::kUndefined);
// 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));
+ 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++) {
- { 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);
+ Handle<String> str =
+ factory->InternalizeUtf8String(constant_string_table[i].contents);
+ roots_[constant_string_table[i].index] = *str;
}
+ Object* 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
// the empty string when searching for the property. It cannot be part of the
@@ -2992,11 +2947,12 @@ bool Heap::CreateInitialObjects() {
CreateFixedStubs();
// Allocate the dictionary of intrinsic function names.
- { MaybeObject* maybe_obj =
- NameDictionary::Allocate(this, Runtime::kNumFunctions);
- if (!maybe_obj->ToObject(&obj)) return false;
+ {
+ Handle<NameDictionary> function_names =
+ NameDictionary::New(isolate(), Runtime::kNumFunctions);
+ Runtime::InitializeIntrinsicFunctionNames(isolate(), function_names);
+ set_intrinsic_function_names(*function_names);
}
- set_intrinsic_function_names(NameDictionary::cast(obj));
{ MaybeObject* maybe_obj = AllocateInitialNumberStringCache();
if (!maybe_obj->ToObject(&obj)) return false;
@@ -3195,60 +3151,58 @@ Object* RegExpResultsCache::Lookup(Heap* heap,
}
-void RegExpResultsCache::Enter(Heap* heap,
- String* key_string,
- Object* key_pattern,
- FixedArray* value_array,
+void RegExpResultsCache::Enter(Isolate* isolate,
+ Handle<String> key_string,
+ Handle<Object> key_pattern,
+ Handle<FixedArray> value_array,
ResultsCacheType type) {
- FixedArray* cache;
+ Factory* factory = isolate->factory();
+ Handle<FixedArray> cache;
if (!key_string->IsInternalizedString()) return;
if (type == STRING_SPLIT_SUBSTRINGS) {
ASSERT(key_pattern->IsString());
if (!key_pattern->IsInternalizedString()) return;
- cache = heap->string_split_cache();
+ cache = factory->string_split_cache();
} else {
ASSERT(type == REGEXP_MULTIPLE_INDICES);
ASSERT(key_pattern->IsFixedArray());
- cache = heap->regexp_multiple_cache();
+ cache = factory->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++) {
- 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);
- }
+ Handle<String> str(String::cast(value_array->get(i)), isolate);
+ Handle<String> internalized_str = factory->InternalizeString(str);
+ value_array->set(i, *internalized_str);
}
}
// Convert backing store to a copy-on-write array.
- value_array->set_map_no_write_barrier(heap->fixed_cow_array_map());
+ value_array->set_map_no_write_barrier(*factory->fixed_cow_array_map());
}
@@ -5987,16 +5941,12 @@ 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