Handlify JSObject::EnsureCanContainHeapObjectElements method.
R=verwaest@chromium.org Review URL: https://codereview.chromium.org/23818005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16595 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
a649a3a254
commit
1a26455d22
@ -1081,13 +1081,6 @@ void Factory::SetContent(Handle<JSArray> array,
|
||||
}
|
||||
|
||||
|
||||
void Factory::EnsureCanContainHeapObjectElements(Handle<JSArray> array) {
|
||||
CALL_HEAP_FUNCTION_VOID(
|
||||
isolate(),
|
||||
array->EnsureCanContainHeapObjectElements());
|
||||
}
|
||||
|
||||
|
||||
void Factory::EnsureCanContainElements(Handle<JSArray> array,
|
||||
Handle<FixedArrayBase> elements,
|
||||
uint32_t length,
|
||||
|
@ -328,7 +328,6 @@ class Factory {
|
||||
|
||||
void SetContent(Handle<JSArray> array, Handle<FixedArrayBase> elements);
|
||||
|
||||
void EnsureCanContainHeapObjectElements(Handle<JSArray> array);
|
||||
void EnsureCanContainElements(Handle<JSArray> array,
|
||||
Handle<FixedArrayBase> elements,
|
||||
uint32_t length,
|
||||
|
@ -1353,17 +1353,16 @@ inline bool AllocationSite::CanTrack(InstanceType type) {
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::EnsureCanContainHeapObjectElements() {
|
||||
ValidateElements();
|
||||
ElementsKind elements_kind = map()->elements_kind();
|
||||
void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object) {
|
||||
object->ValidateElements();
|
||||
ElementsKind elements_kind = object->map()->elements_kind();
|
||||
if (!IsFastObjectElementsKind(elements_kind)) {
|
||||
if (IsFastHoleyElementsKind(elements_kind)) {
|
||||
return TransitionElementsKind(FAST_HOLEY_ELEMENTS);
|
||||
TransitionElementsKind(object, FAST_HOLEY_ELEMENTS);
|
||||
} else {
|
||||
return TransitionElementsKind(FAST_ELEMENTS);
|
||||
TransitionElementsKind(object, FAST_ELEMENTS);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4458,27 +4458,17 @@ void NormalizedMapCache::Clear() {
|
||||
void JSObject::UpdateMapCodeCache(Handle<JSObject> object,
|
||||
Handle<Name> name,
|
||||
Handle<Code> code) {
|
||||
Isolate* isolate = object->GetIsolate();
|
||||
CALL_HEAP_FUNCTION_VOID(isolate,
|
||||
object->UpdateMapCodeCache(*name, *code));
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::UpdateMapCodeCache(Name* name, Code* code) {
|
||||
if (map()->is_shared()) {
|
||||
Handle<Map> map(object->map());
|
||||
if (map->is_shared()) {
|
||||
// Fast case maps are never marked as shared.
|
||||
ASSERT(!HasFastProperties());
|
||||
ASSERT(!object->HasFastProperties());
|
||||
// Replace the map with an identical copy that can be safely modified.
|
||||
Object* obj;
|
||||
{ MaybeObject* maybe_obj = map()->CopyNormalized(KEEP_INOBJECT_PROPERTIES,
|
||||
UNIQUE_NORMALIZED_MAP);
|
||||
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
||||
}
|
||||
GetIsolate()->counters()->normalized_maps()->Increment();
|
||||
|
||||
set_map(Map::cast(obj));
|
||||
map = Map::CopyNormalized(map, KEEP_INOBJECT_PROPERTIES,
|
||||
UNIQUE_NORMALIZED_MAP);
|
||||
object->GetIsolate()->counters()->normalized_maps()->Increment();
|
||||
object->set_map(*map);
|
||||
}
|
||||
return map()->UpdateCodeCache(name, code);
|
||||
Map::UpdateCodeCache(map, name, code);
|
||||
}
|
||||
|
||||
|
||||
@ -6510,6 +6500,15 @@ MaybeObject* Map::RawCopy(int instance_size) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Map> Map::CopyNormalized(Handle<Map> map,
|
||||
PropertyNormalizationMode mode,
|
||||
NormalizedMapSharingMode sharing) {
|
||||
CALL_HEAP_FUNCTION(map->GetIsolate(),
|
||||
map->CopyNormalized(mode, sharing),
|
||||
Map);
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode,
|
||||
NormalizedMapSharingMode sharing) {
|
||||
int new_instance_size = instance_size();
|
||||
@ -9523,21 +9522,13 @@ bool JSFunction::IsInlineable() {
|
||||
|
||||
|
||||
void JSObject::OptimizeAsPrototype(Handle<JSObject> object) {
|
||||
CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), object->OptimizeAsPrototype());
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* JSObject::OptimizeAsPrototype() {
|
||||
if (IsGlobalObject()) return this;
|
||||
if (object->IsGlobalObject()) return;
|
||||
|
||||
// Make sure prototypes are fast objects and their maps have the bit set
|
||||
// so they remain fast.
|
||||
if (!HasFastProperties()) {
|
||||
MaybeObject* new_proto = TransformToFastProperties(0);
|
||||
if (new_proto->IsFailure()) return new_proto;
|
||||
ASSERT(new_proto == this);
|
||||
if (!object->HasFastProperties()) {
|
||||
TransformToFastProperties(object, 0);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2220,7 +2220,6 @@ class JSObject: public JSReceiver {
|
||||
PropertyDetails details);
|
||||
|
||||
static void OptimizeAsPrototype(Handle<JSObject> object);
|
||||
MUST_USE_RESULT MaybeObject* OptimizeAsPrototype();
|
||||
|
||||
// Retrieve interceptors.
|
||||
InterceptorInfo* GetNamedInterceptor();
|
||||
@ -2314,7 +2313,7 @@ class JSObject: public JSReceiver {
|
||||
inline void ValidateElements();
|
||||
|
||||
// Makes sure that this object can contain HeapObject as elements.
|
||||
MUST_USE_RESULT inline MaybeObject* EnsureCanContainHeapObjectElements();
|
||||
static inline void EnsureCanContainHeapObjectElements(Handle<JSObject> obj);
|
||||
|
||||
// Makes sure that this object can contain the specified elements.
|
||||
MUST_USE_RESULT inline MaybeObject* EnsureCanContainElements(
|
||||
@ -2569,8 +2568,6 @@ class JSObject: public JSReceiver {
|
||||
Handle<Name> name,
|
||||
Handle<Code> code);
|
||||
|
||||
MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(Name* name, Code* code);
|
||||
|
||||
// Transform slow named properties to fast variants.
|
||||
// Returns failure if allocation failed.
|
||||
static void TransformToFastProperties(Handle<JSObject> object,
|
||||
@ -5794,6 +5791,9 @@ class Map: public HeapObject {
|
||||
TransitionFlag flag);
|
||||
MUST_USE_RESULT MaybeObject* CopyForObserved();
|
||||
|
||||
static Handle<Map> CopyNormalized(Handle<Map> map,
|
||||
PropertyNormalizationMode mode,
|
||||
NormalizedMapSharingMode sharing);
|
||||
MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode,
|
||||
NormalizedMapSharingMode sharing);
|
||||
|
||||
|
@ -6551,8 +6551,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) {
|
||||
int part_count = indices.length();
|
||||
|
||||
Handle<JSArray> result = isolate->factory()->NewJSArray(part_count);
|
||||
MaybeObject* maybe_result = result->EnsureCanContainHeapObjectElements();
|
||||
if (maybe_result->IsFailure()) return maybe_result;
|
||||
JSObject::EnsureCanContainHeapObjectElements(result);
|
||||
result->set_length(Smi::FromInt(part_count));
|
||||
|
||||
ASSERT(result->HasFastObjectElements());
|
||||
@ -6945,21 +6944,20 @@ static inline void StringBuilderConcatHelper(String* special,
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) {
|
||||
SealHandleScope shs(isolate);
|
||||
HandleScope scope(isolate);
|
||||
ASSERT(args.length() == 3);
|
||||
CONVERT_ARG_CHECKED(JSArray, array, 0);
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0);
|
||||
if (!args[1]->IsSmi()) {
|
||||
isolate->context()->mark_out_of_memory();
|
||||
return Failure::OutOfMemoryException(0x14);
|
||||
}
|
||||
int array_length = args.smi_at(1);
|
||||
CONVERT_ARG_CHECKED(String, special, 2);
|
||||
CONVERT_ARG_HANDLE_CHECKED(String, special, 2);
|
||||
|
||||
// This assumption is used by the slice encoding in one or two smis.
|
||||
ASSERT(Smi::kMaxValue >= String::kMaxLength);
|
||||
|
||||
MaybeObject* maybe_result = array->EnsureCanContainHeapObjectElements();
|
||||
if (maybe_result->IsFailure()) return maybe_result;
|
||||
JSObject::EnsureCanContainHeapObjectElements(array);
|
||||
|
||||
int special_length = special->length();
|
||||
if (!array->HasFastObjectElements()) {
|
||||
@ -7041,7 +7039,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) {
|
||||
if (!maybe_object->ToObject(&object)) return maybe_object;
|
||||
}
|
||||
SeqOneByteString* answer = SeqOneByteString::cast(object);
|
||||
StringBuilderConcatHelper(special,
|
||||
StringBuilderConcatHelper(*special,
|
||||
answer->GetChars(),
|
||||
fixed_array,
|
||||
array_length);
|
||||
@ -7052,7 +7050,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) {
|
||||
if (!maybe_object->ToObject(&object)) return maybe_object;
|
||||
}
|
||||
SeqTwoByteString* answer = SeqTwoByteString::cast(object);
|
||||
StringBuilderConcatHelper(special,
|
||||
StringBuilderConcatHelper(*special,
|
||||
answer->GetChars(),
|
||||
fixed_array,
|
||||
array_length);
|
||||
@ -9411,9 +9409,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) {
|
||||
|
||||
CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1);
|
||||
|
||||
MaybeObject* maybe_result_array =
|
||||
output->EnsureCanContainHeapObjectElements();
|
||||
if (maybe_result_array->IsFailure()) return maybe_result_array;
|
||||
JSObject::EnsureCanContainHeapObjectElements(output);
|
||||
RUNTIME_ASSERT(output->HasFastObjectElements());
|
||||
|
||||
DisallowHeapAllocation no_gc;
|
||||
|
Loading…
Reference in New Issue
Block a user