From: yangguo@chromium.org Date: Tue, 29 Apr 2014 07:02:11 +0000 (+0000) Subject: Refactor calls to CALL_HEAP_FUNCTION. X-Git-Tag: upstream/4.7.83~9369 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=14f132c2d9a66f19cb47b7820b3e9978d8e590b1;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/api.cc b/src/api.cc index f58867d..b62e59d 100644 --- a/src/api.cc +++ b/src/api.cc @@ -3560,7 +3560,7 @@ Local v8::Object::Clone() { ENTER_V8(isolate); i::Handle self = Utils::OpenHandle(this); EXCEPTION_PREAMBLE(isolate); - i::Handle result = i::JSObject::Copy(self); + i::Handle result = isolate->factory()->CopyJSObject(self); has_pending_exception = result.is_null(); EXCEPTION_BAILOUT_CHECK(isolate, Local()); return Utils::ToLocal(result); @@ -5774,7 +5774,8 @@ Local Array::CloneElementAt(uint32_t index) { i::Handle paragon_handle(i::JSObject::cast(paragon)); EXCEPTION_PREAMBLE(isolate); ENTER_V8(isolate); - i::Handle result = i::JSObject::Copy(paragon_handle); + i::Handle result = + isolate->factory()->CopyJSObject(paragon_handle); has_pending_exception = result.is_null(); EXCEPTION_BAILOUT_CHECK(isolate, Local()); return Utils::ToLocal(result); diff --git a/src/factory.cc b/src/factory.cc index a085bba..22b6489 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -418,13 +418,6 @@ Handle ConcatStringContent(Handle result, } -Handle Factory::NewRawConsString(String::Encoding encoding) { - Handle map = (encoding == String::ONE_BYTE_ENCODING) - ? cons_ascii_string_map() : cons_string_map(); - return New(map, NEW_SPACE); -} - - MaybeHandle Factory::NewConsString(Handle left, Handle right) { int left_length = left->length(); @@ -494,10 +487,9 @@ MaybeHandle Factory::NewConsString(Handle left, NewRawTwoByteString(length).ToHandleChecked(), left, right); } - Handle result = NewRawConsString( - (is_one_byte || is_one_byte_data_in_two_byte_string) - ? String::ONE_BYTE_ENCODING - : String::TWO_BYTE_ENCODING); + Handle map = (is_one_byte || is_one_byte_data_in_two_byte_string) + ? cons_ascii_string_map() : cons_string_map(); + Handle result = New(map, NEW_SPACE); DisallowHeapAllocation no_gc; WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); @@ -523,13 +515,6 @@ Handle Factory::NewFlatConcatString(Handle first, } -Handle Factory::NewRawSlicedString(String::Encoding encoding) { - Handle map = (encoding == String::ONE_BYTE_ENCODING) - ? sliced_ascii_string_map() : sliced_string_map(); - return New(map, NEW_SPACE); -} - - Handle Factory::NewProperSubString(Handle str, int begin, int end) { @@ -581,9 +566,9 @@ Handle Factory::NewProperSubString(Handle str, } ASSERT(str->IsSeqString() || str->IsExternalString()); - Handle slice = NewRawSlicedString( - str->IsOneByteRepresentation() ? String::ONE_BYTE_ENCODING - : String::TWO_BYTE_ENCODING); + Handle map = str->IsOneByteRepresentation() ? sliced_ascii_string_map() + : sliced_string_map(); + Handle slice = New(map, NEW_SPACE); slice->set_hash_field(String::kEmptyHashField); slice->set_length(length); @@ -953,6 +938,24 @@ Handle Factory::NewFunctionPrototype(Handle function) { } +Handle Factory::CopyJSObject(Handle object) { + CALL_HEAP_FUNCTION(isolate(), + isolate()->heap()->CopyJSObject(*object, NULL), + JSObject); +} + + +Handle Factory::CopyJSObjectWithAllocationSite( + Handle object, + Handle site) { + CALL_HEAP_FUNCTION(isolate(), + isolate()->heap()->CopyJSObject( + *object, + site.is_null() ? NULL : *site), + JSObject); +} + + Handle Factory::CopyFixedArrayWithMap(Handle array, Handle map) { CALL_HEAP_FUNCTION(isolate(), diff --git a/src/factory.h b/src/factory.h index ccd0a57..0cc7c59 100644 --- a/src/factory.h +++ b/src/factory.h @@ -179,8 +179,6 @@ class Factory V8_FINAL { MUST_USE_RESULT MaybeHandle NewConsString(Handle left, Handle right); - Handle NewRawConsString(String::Encoding encoding); - // Create a new sequential string containing the concatenation of the inputs. Handle NewFlatConcatString(Handle first, Handle second); @@ -196,8 +194,6 @@ class Factory V8_FINAL { return NewProperSubString(str, begin, end); } - Handle 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 NewFunctionPrototype(Handle function); + Handle CopyJSObject(Handle object); + + Handle CopyJSObjectWithAllocationSite(Handle object, + Handle site); + Handle CopyFixedArrayWithMap(Handle array, Handle map); diff --git a/src/isolate.cc b/src/isolate.cc index 2110e7e..e0e1c26 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -792,7 +792,7 @@ Object* Isolate::StackOverflow() { Handle key = factory()->stack_overflow_string(); Handle boilerplate = Handle::cast( Object::GetProperty(js_builtins_object(), key).ToHandleChecked()); - Handle exception = JSObject::Copy(boilerplate); + Handle exception = factory()->CopyJSObject(boilerplate); DoThrow(*exception, NULL); // Get stack trace limit. diff --git a/src/objects.cc b/src/objects.cc index e021858..1e9ec61 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -5970,25 +5970,6 @@ void JSObject::SetObserved(Handle object) { } -Handle JSObject::Copy(Handle object, - Handle site) { - Isolate* isolate = object->GetIsolate(); - CALL_HEAP_FUNCTION(isolate, - isolate->heap()->CopyJSObject( - *object, - site.is_null() ? NULL : *site), - JSObject); -} - - -Handle JSObject::Copy(Handle object) { - Isolate* isolate = object->GetIsolate(); - CALL_HEAP_FUNCTION(isolate, - isolate->heap()->CopyJSObject(*object, NULL), - JSObject); -} - - Handle JSObject::FastPropertyAt(Handle object, Representation representation, int index) { @@ -6057,7 +6038,8 @@ MaybeHandle JSObjectWalkVisitor::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; } diff --git a/src/objects.h b/src/objects.h index f10c607..0ce8f97 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2630,8 +2630,6 @@ class JSObject: public JSReceiver { kObjectIsShallowArray = 1 }; - static Handle Copy(Handle object, - Handle site); static Handle Copy(Handle object); MUST_USE_RESULT static MaybeHandle DeepCopy( Handle object, diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc index 2001b3d..3a5820d 100644 --- a/test/cctest/test-heap.cc +++ b/test/cctest/test-heap.cc @@ -818,7 +818,7 @@ TEST(JSObjectCopy) { // Make the clone. Handle value1, value2; - Handle clone = JSObject::Copy(obj); + Handle clone = factory->CopyJSObject(obj); CHECK(!clone.is_identical_to(obj)); value1 = Object::GetElement(isolate, obj, 0).ToHandleChecked();