Refactor calls to CALL_HEAP_FUNCTION.

R=mvstanton@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@21036 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2014-04-29 07:02:11 +00:00
parent d4b533d41b
commit 14f132c2d9
7 changed files with 36 additions and 51 deletions

View File

@ -3560,7 +3560,7 @@ Local<v8::Object> v8::Object::Clone() {
ENTER_V8(isolate);
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
EXCEPTION_PREAMBLE(isolate);
i::Handle<i::JSObject> result = i::JSObject::Copy(self);
i::Handle<i::JSObject> result = isolate->factory()->CopyJSObject(self);
has_pending_exception = result.is_null();
EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
return Utils::ToLocal(result);
@ -5774,7 +5774,8 @@ Local<Object> Array::CloneElementAt(uint32_t index) {
i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon));
EXCEPTION_PREAMBLE(isolate);
ENTER_V8(isolate);
i::Handle<i::JSObject> result = i::JSObject::Copy(paragon_handle);
i::Handle<i::JSObject> result =
isolate->factory()->CopyJSObject(paragon_handle);
has_pending_exception = result.is_null();
EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
return Utils::ToLocal(result);

View File

@ -418,13 +418,6 @@ Handle<String> ConcatStringContent(Handle<StringType> result,
}
Handle<ConsString> Factory::NewRawConsString(String::Encoding encoding) {
Handle<Map> map = (encoding == String::ONE_BYTE_ENCODING)
? cons_ascii_string_map() : cons_string_map();
return New<ConsString>(map, NEW_SPACE);
}
MaybeHandle<String> Factory::NewConsString(Handle<String> left,
Handle<String> right) {
int left_length = left->length();
@ -494,10 +487,9 @@ MaybeHandle<String> Factory::NewConsString(Handle<String> left,
NewRawTwoByteString(length).ToHandleChecked(), left, right);
}
Handle<ConsString> result = NewRawConsString(
(is_one_byte || is_one_byte_data_in_two_byte_string)
? String::ONE_BYTE_ENCODING
: String::TWO_BYTE_ENCODING);
Handle<Map> map = (is_one_byte || is_one_byte_data_in_two_byte_string)
? cons_ascii_string_map() : cons_string_map();
Handle<ConsString> result = New<ConsString>(map, NEW_SPACE);
DisallowHeapAllocation no_gc;
WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
@ -523,13 +515,6 @@ Handle<String> Factory::NewFlatConcatString(Handle<String> first,
}
Handle<SlicedString> Factory::NewRawSlicedString(String::Encoding encoding) {
Handle<Map> map = (encoding == String::ONE_BYTE_ENCODING)
? sliced_ascii_string_map() : sliced_string_map();
return New<SlicedString>(map, NEW_SPACE);
}
Handle<String> Factory::NewProperSubString(Handle<String> str,
int begin,
int end) {
@ -581,9 +566,9 @@ Handle<String> Factory::NewProperSubString(Handle<String> str,
}
ASSERT(str->IsSeqString() || str->IsExternalString());
Handle<SlicedString> slice = NewRawSlicedString(
str->IsOneByteRepresentation() ? String::ONE_BYTE_ENCODING
: String::TWO_BYTE_ENCODING);
Handle<Map> map = str->IsOneByteRepresentation() ? sliced_ascii_string_map()
: sliced_string_map();
Handle<SlicedString> slice = New<SlicedString>(map, NEW_SPACE);
slice->set_hash_field(String::kEmptyHashField);
slice->set_length(length);
@ -953,6 +938,24 @@ Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
}
Handle<JSObject> Factory::CopyJSObject(Handle<JSObject> object) {
CALL_HEAP_FUNCTION(isolate(),
isolate()->heap()->CopyJSObject(*object, NULL),
JSObject);
}
Handle<JSObject> Factory::CopyJSObjectWithAllocationSite(
Handle<JSObject> object,
Handle<AllocationSite> site) {
CALL_HEAP_FUNCTION(isolate(),
isolate()->heap()->CopyJSObject(
*object,
site.is_null() ? NULL : *site),
JSObject);
}
Handle<FixedArray> Factory::CopyFixedArrayWithMap(Handle<FixedArray> array,
Handle<Map> map) {
CALL_HEAP_FUNCTION(isolate(),

View File

@ -179,8 +179,6 @@ class Factory V8_FINAL {
MUST_USE_RESULT MaybeHandle<String> NewConsString(Handle<String> left,
Handle<String> right);
Handle<ConsString> NewRawConsString(String::Encoding encoding);
// Create a new sequential string containing the concatenation of the inputs.
Handle<String> NewFlatConcatString(Handle<String> first,
Handle<String> second);
@ -196,8 +194,6 @@ class Factory V8_FINAL {
return NewProperSubString(str, begin, end);
}
Handle<SlicedString> NewRawSlicedString(String::Encoding encoding);
// Creates a new external String object. There are two String encodings
// in the system: ASCII and two byte. Unlike other String types, it does
// not make sense to have a UTF-8 factory function for external strings,
@ -300,6 +296,11 @@ class Factory V8_FINAL {
Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
Handle<JSObject> CopyJSObject(Handle<JSObject> object);
Handle<JSObject> CopyJSObjectWithAllocationSite(Handle<JSObject> object,
Handle<AllocationSite> site);
Handle<FixedArray> CopyFixedArrayWithMap(Handle<FixedArray> array,
Handle<Map> map);

View File

@ -792,7 +792,7 @@ Object* Isolate::StackOverflow() {
Handle<String> key = factory()->stack_overflow_string();
Handle<JSObject> boilerplate = Handle<JSObject>::cast(
Object::GetProperty(js_builtins_object(), key).ToHandleChecked());
Handle<JSObject> exception = JSObject::Copy(boilerplate);
Handle<JSObject> exception = factory()->CopyJSObject(boilerplate);
DoThrow(*exception, NULL);
// Get stack trace limit.

View File

@ -5970,25 +5970,6 @@ void JSObject::SetObserved(Handle<JSObject> object) {
}
Handle<JSObject> JSObject::Copy(Handle<JSObject> object,
Handle<AllocationSite> site) {
Isolate* isolate = object->GetIsolate();
CALL_HEAP_FUNCTION(isolate,
isolate->heap()->CopyJSObject(
*object,
site.is_null() ? NULL : *site),
JSObject);
}
Handle<JSObject> JSObject::Copy(Handle<JSObject> object) {
Isolate* isolate = object->GetIsolate();
CALL_HEAP_FUNCTION(isolate,
isolate->heap()->CopyJSObject(*object, NULL),
JSObject);
}
Handle<Object> JSObject::FastPropertyAt(Handle<JSObject> object,
Representation representation,
int index) {
@ -6057,7 +6038,8 @@ MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
if (site_context()->ShouldCreateMemento(object)) {
site_to_pass = site_context()->current();
}
copy = JSObject::Copy(object, site_to_pass);
copy = isolate->factory()->CopyJSObjectWithAllocationSite(
object, site_to_pass);
} else {
copy = object;
}

View File

@ -2630,8 +2630,6 @@ class JSObject: public JSReceiver {
kObjectIsShallowArray = 1
};
static Handle<JSObject> Copy(Handle<JSObject> object,
Handle<AllocationSite> site);
static Handle<JSObject> Copy(Handle<JSObject> object);
MUST_USE_RESULT static MaybeHandle<JSObject> DeepCopy(
Handle<JSObject> object,

View File

@ -818,7 +818,7 @@ TEST(JSObjectCopy) {
// Make the clone.
Handle<Object> value1, value2;
Handle<JSObject> clone = JSObject::Copy(obj);
Handle<JSObject> clone = factory->CopyJSObject(obj);
CHECK(!clone.is_identical_to(obj));
value1 = Object::GetElement(isolate, obj, 0).ToHandleChecked();