Commit dd206283 authored by ishell@chromium.org's avatar ishell@chromium.org

Reland r20772 "Handlifying clients of StringTable, step 1."

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/238263003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20813 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f70a26bc
......@@ -39,6 +39,16 @@ 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,6 +14,11 @@ 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,
......
This diff is collapsed.
......@@ -2009,11 +2009,6 @@ 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();
......@@ -2787,10 +2782,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(Heap* heap,
String* key_string,
Object* key_pattern,
FixedArray* value_array,
static void Enter(Isolate* isolate,
Handle<String> key_string,
Handle<Object> key_pattern,
Handle<FixedArray> value_array,
ResultsCacheType type);
static void Clear(FixedArray* cache);
static const int kRegExpResultsCacheSize = 0x100;
......
......@@ -10393,20 +10393,16 @@ bool JSFunction::PassesFilter(const char* raw_filter) {
}
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;
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);
}
......@@ -14874,6 +14870,10 @@ Dictionary<UnseededNumberDictionary, UnseededNumberDictionaryShape, uint32_t>::
template MaybeObject* Dictionary<NameDictionary, NameDictionaryShape, Name*>::
Allocate(Heap* heap, int n, PretenureFlag pretenure);
template Handle<NameDictionary>
Dictionary<NameDictionary, NameDictionaryShape, Name*>::
New(Isolate* isolate, int n, PretenureFlag pretenure);
template MaybeObject*
Dictionary<SeededNumberDictionary, SeededNumberDictionaryShape, uint32_t>::
AtPut(uint32_t, Object*);
......@@ -14926,6 +14926,10 @@ 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);
......@@ -15788,6 +15792,23 @@ MaybeObject* Dictionary<Derived, Shape, Key>::Allocate(
}
template<typename Derived, typename Shape, typename Key>
Handle<Derived> Dictionary<Derived, Shape, Key>::New(
Isolate* isolate,
int at_least_space_for,
PretenureFlag pretenure) {
Handle<Derived> dict = DerivedHashTable::New(isolate,
at_least_space_for,
USE_DEFAULT_MINIMUM_CAPACITY,
pretenure);
// Initialize the next enumeration index.
dict->SetNextEnumerationIndex(PropertyDetails::kInitialIndex);
return dict;
}
void NameDictionary::DoGenerateNewEnumerationIndices(
Handle<NameDictionary> dictionary) {
CALL_HEAP_FUNCTION_VOID(dictionary->GetIsolate(),
......
......@@ -4054,6 +4054,12 @@ class Dictionary: public HashTable<Derived, Shape, Key> {
int at_least_space_for,
PretenureFlag pretenure = NOT_TENURED);
// Creates a new dictionary.
static Handle<Derived> New(
Isolate* isolate,
int at_least_space_for,
PretenureFlag pretenure = NOT_TENURED);
// Ensure enough space for n additional elements.
MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key);
......@@ -9757,10 +9763,11 @@ class Oddball: public HeapObject {
DECLARE_VERIFIER(Oddball)
// Initialize the fields.
MUST_USE_RESULT MaybeObject* Initialize(Heap* heap,
const char* to_string,
Object* to_number,
byte kind);
static void Initialize(Isolate* isolate,
Handle<Oddball> oddball,
const char* to_string,
Handle<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->heap(),
*subject,
regexp->data(),
*fixed_array,
RegExpResultsCache::Enter(isolate,
subject,
handle(regexp->data(), isolate),
fixed_array,
RegExpResultsCache::REGEXP_MULTIPLE_INDICES);
}
return *builder.ToJSArray(result_array);
......@@ -6757,10 +6757,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
if (limit == 0xffffffffu) {
if (result->HasFastObjectElements()) {
RegExpResultsCache::Enter(isolate->heap(),
*subject,
*pattern,
*elements,
RegExpResultsCache::Enter(isolate,
subject,
pattern,
elements,
RegExpResultsCache::STRING_SPLIT_SUBSTRINGS);
}
}
......
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