Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 5401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5412 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); | 5412 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); |
| 5413 EnsureInitializedForIsolate(isolate, location); | 5413 EnsureInitializedForIsolate(isolate, location); |
| 5414 LOG_API(isolate, env); | 5414 LOG_API(isolate, env); |
| 5415 if (length == 0 && type != String::kUndetectableString) { | 5415 if (length == 0 && type != String::kUndetectableString) { |
| 5416 return String::Empty(v8_isolate); | 5416 return String::Empty(v8_isolate); |
| 5417 } | 5417 } |
| 5418 ENTER_V8(isolate); | 5418 ENTER_V8(isolate); |
| 5419 if (length == -1) length = StringLength(data); | 5419 if (length == -1) length = StringLength(data); |
| 5420 i::Handle<i::String> result = NewString( | 5420 i::Handle<i::String> result = NewString( |
| 5421 isolate->factory(), type, i::Vector<const Char>(data, length)); | 5421 isolate->factory(), type, i::Vector<const Char>(data, length)); |
| 5422 // We do not expect this to fail. Change this if it does. | |
| 5423 CHECK(!result.is_null()); | |
|
Yang
2014/03/21 12:32:18
Not using CHECK_NOT_EMPTY_HANDLE because this coul
| |
| 5422 if (type == String::kUndetectableString) { | 5424 if (type == String::kUndetectableString) { |
| 5423 result->MarkAsUndetectable(); | 5425 result->MarkAsUndetectable(); |
| 5424 } | 5426 } |
| 5425 return Utils::ToLocal(result); | 5427 return Utils::ToLocal(result); |
| 5426 } | 5428 } |
| 5427 | 5429 |
| 5428 } // anonymous namespace | 5430 } // anonymous namespace |
| 5429 | 5431 |
| 5430 | 5432 |
| 5431 Local<String> String::NewFromUtf8(Isolate* isolate, | 5433 Local<String> String::NewFromUtf8(Isolate* isolate, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5469 | 5471 |
| 5470 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { | 5472 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { |
| 5471 i::Handle<i::String> left_string = Utils::OpenHandle(*left); | 5473 i::Handle<i::String> left_string = Utils::OpenHandle(*left); |
| 5472 i::Isolate* isolate = left_string->GetIsolate(); | 5474 i::Isolate* isolate = left_string->GetIsolate(); |
| 5473 EnsureInitializedForIsolate(isolate, "v8::String::New()"); | 5475 EnsureInitializedForIsolate(isolate, "v8::String::New()"); |
| 5474 LOG_API(isolate, "String::New(char)"); | 5476 LOG_API(isolate, "String::New(char)"); |
| 5475 ENTER_V8(isolate); | 5477 ENTER_V8(isolate); |
| 5476 i::Handle<i::String> right_string = Utils::OpenHandle(*right); | 5478 i::Handle<i::String> right_string = Utils::OpenHandle(*right); |
| 5477 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, | 5479 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, |
| 5478 right_string); | 5480 right_string); |
| 5479 // We do not expect this to throw an exception. Change this if it does. | 5481 // We do not expect this to fail. Change this if it does. |
| 5480 CHECK_NOT_EMPTY_HANDLE(isolate, result); | 5482 CHECK(!result.is_null()); |
| 5481 return Utils::ToLocal(result); | 5483 return Utils::ToLocal(result); |
| 5482 } | 5484 } |
| 5483 | 5485 |
| 5484 | 5486 |
| 5485 static i::Handle<i::String> NewExternalStringHandle( | 5487 static i::Handle<i::String> NewExternalStringHandle( |
| 5486 i::Isolate* isolate, | 5488 i::Isolate* isolate, |
| 5487 v8::String::ExternalStringResource* resource) { | 5489 v8::String::ExternalStringResource* resource) { |
| 5488 return isolate->factory()->NewExternalStringFromTwoByte(resource); | 5490 i::Handle<i::String> result = |
| 5491 isolate->factory()->NewExternalStringFromTwoByte(resource); | |
| 5492 // We do not expect this to fail. Change this if it does. | |
| 5493 CHECK(!result.is_null()); | |
| 5494 return result; | |
| 5489 } | 5495 } |
| 5490 | 5496 |
| 5491 | 5497 |
| 5492 static i::Handle<i::String> NewExternalAsciiStringHandle( | 5498 static i::Handle<i::String> NewExternalAsciiStringHandle( |
| 5493 i::Isolate* isolate, | 5499 i::Isolate* isolate, |
| 5494 v8::String::ExternalAsciiStringResource* resource) { | 5500 v8::String::ExternalAsciiStringResource* resource) { |
| 5495 return isolate->factory()->NewExternalStringFromAscii(resource); | 5501 i::Handle<i::String> result = |
| 5502 isolate->factory()->NewExternalStringFromAscii(resource); | |
| 5503 // We do not expect this to fail. Change this if it does. | |
| 5504 CHECK(!result.is_null()); | |
| 5505 return result; | |
| 5496 } | 5506 } |
| 5497 | 5507 |
| 5498 | 5508 |
| 5499 Local<String> v8::String::NewExternal( | 5509 Local<String> v8::String::NewExternal( |
| 5500 Isolate* isolate, | 5510 Isolate* isolate, |
| 5501 v8::String::ExternalStringResource* resource) { | 5511 v8::String::ExternalStringResource* resource) { |
| 5502 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5512 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 5503 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); | 5513 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
| 5504 LOG_API(i_isolate, "String::NewExternal"); | 5514 LOG_API(i_isolate, "String::NewExternal"); |
| 5505 ENTER_V8(i_isolate); | 5515 ENTER_V8(i_isolate); |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6139 Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) { | 6149 Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) { |
| 6140 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6150 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6141 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); | 6151 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); |
| 6142 LOG_API(i_isolate, "Symbol::New()"); | 6152 LOG_API(i_isolate, "Symbol::New()"); |
| 6143 ENTER_V8(i_isolate); | 6153 ENTER_V8(i_isolate); |
| 6144 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); | 6154 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); |
| 6145 if (data != NULL) { | 6155 if (data != NULL) { |
| 6146 if (length == -1) length = i::StrLength(data); | 6156 if (length == -1) length = i::StrLength(data); |
| 6147 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( | 6157 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( |
| 6148 i::Vector<const char>(data, length)); | 6158 i::Vector<const char>(data, length)); |
| 6159 // We do not expect this to fail. Change this if it does. | |
| 6160 CHECK(!name.is_null()); | |
| 6149 result->set_name(*name); | 6161 result->set_name(*name); |
| 6150 } | 6162 } |
| 6151 return Utils::ToLocal(result); | 6163 return Utils::ToLocal(result); |
| 6152 } | 6164 } |
| 6153 | 6165 |
| 6154 | 6166 |
| 6155 Local<Private> v8::Private::New( | 6167 Local<Private> v8::Private::New( |
| 6156 Isolate* isolate, Local<String> name) { | 6168 Isolate* isolate, Local<String> name) { |
| 6157 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6169 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6158 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); | 6170 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); |
| (...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6965 i::Isolate* isolate = i::Isolate::Current(); | 6977 i::Isolate* isolate = i::Isolate::Current(); |
| 6966 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6978 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 6967 const i::CodeEntry* entry = node->entry(); | 6979 const i::CodeEntry* entry = node->entry(); |
| 6968 if (!entry->has_name_prefix()) { | 6980 if (!entry->has_name_prefix()) { |
| 6969 return ToApiHandle<String>( | 6981 return ToApiHandle<String>( |
| 6970 isolate->factory()->InternalizeUtf8String(entry->name())); | 6982 isolate->factory()->InternalizeUtf8String(entry->name())); |
| 6971 } else { | 6983 } else { |
| 6972 i::Handle<i::String> cons = isolate->factory()->NewConsString( | 6984 i::Handle<i::String> cons = isolate->factory()->NewConsString( |
| 6973 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), | 6985 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), |
| 6974 isolate->factory()->InternalizeUtf8String(entry->name())); | 6986 isolate->factory()->InternalizeUtf8String(entry->name())); |
| 6975 // We do not expect this to throw an exception. Change this if it does. | 6987 // We do not expect this to fail. Change this if it does. |
| 6976 CHECK_NOT_EMPTY_HANDLE(isolate, cons); | 6988 CHECK(!cons.is_null()); |
| 6977 return ToApiHandle<String>(cons); | 6989 return ToApiHandle<String>(cons); |
| 6978 } | 6990 } |
| 6979 } | 6991 } |
| 6980 | 6992 |
| 6981 | 6993 |
| 6982 int CpuProfileNode::GetScriptId() const { | 6994 int CpuProfileNode::GetScriptId() const { |
| 6983 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6995 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 6984 const i::CodeEntry* entry = node->entry(); | 6996 const i::CodeEntry* entry = node->entry(); |
| 6985 return entry->script_id(); | 6997 return entry->script_id(); |
| 6986 } | 6998 } |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7597 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7609 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7598 Address callback_address = | 7610 Address callback_address = |
| 7599 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7611 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7600 VMState<EXTERNAL> state(isolate); | 7612 VMState<EXTERNAL> state(isolate); |
| 7601 ExternalCallbackScope call_scope(isolate, callback_address); | 7613 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7602 callback(info); | 7614 callback(info); |
| 7603 } | 7615 } |
| 7604 | 7616 |
| 7605 | 7617 |
| 7606 } } // namespace v8::internal | 7618 } } // namespace v8::internal |
| OLD | NEW |