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