Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: src/api.cc

Issue 199583007: Reland "Throw exception on invalid string length instead of OOM." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: change Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 5457 matching lines...) Expand 10 before | Expand all | Expand 10 after
5468 5468
5469 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { 5469 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
5470 i::Handle<i::String> left_string = Utils::OpenHandle(*left); 5470 i::Handle<i::String> left_string = Utils::OpenHandle(*left);
5471 i::Isolate* isolate = left_string->GetIsolate(); 5471 i::Isolate* isolate = left_string->GetIsolate();
5472 EnsureInitializedForIsolate(isolate, "v8::String::New()"); 5472 EnsureInitializedForIsolate(isolate, "v8::String::New()");
5473 LOG_API(isolate, "String::New(char)"); 5473 LOG_API(isolate, "String::New(char)");
5474 ENTER_V8(isolate); 5474 ENTER_V8(isolate);
5475 i::Handle<i::String> right_string = Utils::OpenHandle(*right); 5475 i::Handle<i::String> right_string = Utils::OpenHandle(*right);
5476 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, 5476 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string,
5477 right_string); 5477 right_string);
5478 // We do not expect this to throw an exception. Change this if it does.
5479 CHECK_NOT_EMPTY_HANDLE(isolate, result);
5478 return Utils::ToLocal(result); 5480 return Utils::ToLocal(result);
5479 } 5481 }
5480 5482
5481 5483
5482 static i::Handle<i::String> NewExternalStringHandle( 5484 static i::Handle<i::String> NewExternalStringHandle(
5483 i::Isolate* isolate, 5485 i::Isolate* isolate,
5484 v8::String::ExternalStringResource* resource) { 5486 v8::String::ExternalStringResource* resource) {
5485 return isolate->factory()->NewExternalStringFromTwoByte(resource); 5487 return isolate->factory()->NewExternalStringFromTwoByte(resource);
5486 } 5488 }
5487 5489
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
6959 6961
6960 6962
6961 Handle<String> CpuProfileNode::GetFunctionName() const { 6963 Handle<String> CpuProfileNode::GetFunctionName() const {
6962 i::Isolate* isolate = i::Isolate::Current(); 6964 i::Isolate* isolate = i::Isolate::Current();
6963 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 6965 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
6964 const i::CodeEntry* entry = node->entry(); 6966 const i::CodeEntry* entry = node->entry();
6965 if (!entry->has_name_prefix()) { 6967 if (!entry->has_name_prefix()) {
6966 return ToApiHandle<String>( 6968 return ToApiHandle<String>(
6967 isolate->factory()->InternalizeUtf8String(entry->name())); 6969 isolate->factory()->InternalizeUtf8String(entry->name()));
6968 } else { 6970 } else {
6969 return ToApiHandle<String>(isolate->factory()->NewConsString( 6971 i::Handle<i::String> cons = isolate->factory()->NewConsString(
6970 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), 6972 isolate->factory()->InternalizeUtf8String(entry->name_prefix()),
6971 isolate->factory()->InternalizeUtf8String(entry->name()))); 6973 isolate->factory()->InternalizeUtf8String(entry->name()));
6974 // We do not expect this to throw an exception. Change this if it does.
6975 CHECK_NOT_EMPTY_HANDLE(isolate, cons);
6976 return ToApiHandle<String>(cons);
6972 } 6977 }
6973 } 6978 }
6974 6979
6975 6980
6976 int CpuProfileNode::GetScriptId() const { 6981 int CpuProfileNode::GetScriptId() const {
6977 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 6982 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
6978 const i::CodeEntry* entry = node->entry(); 6983 const i::CodeEntry* entry = node->entry();
6979 return entry->script_id(); 6984 return entry->script_id();
6980 } 6985 }
6981 6986
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
7591 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7596 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7592 Address callback_address = 7597 Address callback_address =
7593 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7598 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7594 VMState<EXTERNAL> state(isolate); 7599 VMState<EXTERNAL> state(isolate);
7595 ExternalCallbackScope call_scope(isolate, callback_address); 7600 ExternalCallbackScope call_scope(isolate, callback_address);
7596 callback(info); 7601 callback(info);
7597 } 7602 }
7598 7603
7599 7604
7600 } } // namespace v8::internal 7605 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698