Commit eedc4c01 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Return MaybeHandle from NewExternalStringFrom*.

R=ishell@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20481 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 164e5b58
......@@ -5469,22 +5469,18 @@ Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
static i::Handle<i::String> NewExternalStringHandle(
i::Isolate* isolate,
v8::String::ExternalStringResource* resource) {
i::Handle<i::String> result =
isolate->factory()->NewExternalStringFromTwoByte(resource);
// We do not expect this to fail. Change this if it does.
CHECK(!result.is_null());
return result;
return isolate->factory()->NewExternalStringFromTwoByte(
resource).ToHandleChecked();
}
static i::Handle<i::String> NewExternalAsciiStringHandle(
i::Isolate* isolate,
v8::String::ExternalAsciiStringResource* resource) {
i::Handle<i::String> result =
isolate->factory()->NewExternalStringFromAscii(resource);
// We do not expect this to fail. Change this if it does.
CHECK(!result.is_null());
return result;
return isolate->factory()->NewExternalStringFromAscii(
resource).ToHandleChecked();
}
......
......@@ -53,10 +53,10 @@ Handle<String> Bootstrapper::NativesSourceLookup(int index) {
new NativesExternalStringResource(this,
source.start(),
source.length());
Handle<String> source_code =
isolate_->factory()->NewExternalStringFromAscii(resource);
// We do not expect this to throw an exception. Change this if it does.
CHECK_NOT_EMPTY_HANDLE(isolate_, source_code);
Handle<String> source_code =
isolate_->factory()->NewExternalStringFromAscii(
resource).ToHandleChecked();
heap->natives_source_cache()->set(index, *source_code);
}
Handle<Object> cached_source(heap->natives_source_cache()->get(index),
......@@ -2319,10 +2319,10 @@ bool Genesis::InstallExtension(Isolate* isolate,
return false;
}
}
Handle<String> source_code =
isolate->factory()->NewExternalStringFromAscii(extension->source());
// We do not expect this to throw an exception. Change this if it does.
CHECK_NOT_EMPTY_HANDLE(isolate, source_code);
Handle<String> source_code =
isolate->factory()->NewExternalStringFromAscii(
extension->source()).ToHandleChecked();
bool result = CompileScriptCached(isolate,
CStrVector(extension->name()),
source_code,
......
......@@ -523,7 +523,7 @@ Handle<String> Factory::NewProperSubString(Handle<String> str,
}
Handle<String> Factory::NewExternalStringFromAscii(
MaybeHandle<String> Factory::NewExternalStringFromAscii(
const ExternalAsciiString::Resource* resource) {
CALL_HEAP_FUNCTION(
isolate(),
......@@ -532,7 +532,7 @@ Handle<String> Factory::NewExternalStringFromAscii(
}
Handle<String> Factory::NewExternalStringFromTwoByte(
MaybeHandle<String> Factory::NewExternalStringFromTwoByte(
const ExternalTwoByteString::Resource* resource) {
CALL_HEAP_FUNCTION(
isolate(),
......
......@@ -166,9 +166,9 @@ class Factory V8_FINAL {
// 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,
// because we cannot change the underlying buffer.
Handle<String> NewExternalStringFromAscii(
MaybeHandle<String> NewExternalStringFromAscii(
const ExternalAsciiString::Resource* resource);
Handle<String> NewExternalStringFromTwoByte(
MaybeHandle<String> NewExternalStringFromTwoByte(
const ExternalTwoByteString::Resource* resource);
// Create a symbol.
......
......@@ -15122,9 +15122,11 @@ THREADED_TEST(MorphCompositeStringTest) {
i::StrLength(c_string)));
Local<String> lhs(v8::Utils::ToLocal(
factory->NewExternalStringFromAscii(&ascii_resource)));
factory->NewExternalStringFromAscii(&ascii_resource)
.ToHandleChecked()));
Local<String> rhs(v8::Utils::ToLocal(
factory->NewExternalStringFromAscii(&ascii_resource)));
factory->NewExternalStringFromAscii(&ascii_resource)
.ToHandleChecked()));
env->Global()->Set(v8_str("lhs"), lhs);
env->Global()->Set(v8_str("rhs"), rhs);
......
......@@ -655,7 +655,7 @@ void TestCharacterStream(const char* ascii_source,
factory->NewStringFromAscii(ascii_vector));
TestExternalResource resource(uc16_buffer.get(), length);
i::Handle<i::String> uc16_string(
factory->NewExternalStringFromTwoByte(&resource));
factory->NewExternalStringFromTwoByte(&resource).ToHandleChecked());
i::ExternalTwoByteStringUtf16CharacterStream uc16_stream(
i::Handle<i::ExternalTwoByteString>::cast(uc16_string), start, end);
......
......@@ -1137,7 +1137,8 @@ TEST(SliceFromExternal) {
v8::HandleScope scope(CcTest::isolate());
AsciiVectorResource resource(
i::Vector<const char>("abcdefghijklmnopqrstuvwxyz", 26));
Handle<String> string = factory->NewExternalStringFromAscii(&resource);
Handle<String> string =
factory->NewExternalStringFromAscii(&resource).ToHandleChecked();
CHECK(string->IsExternalString());
Handle<String> slice = factory->NewSubString(string, 1, 25);
CHECK(slice->IsSlicedString());
......
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