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 5411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5422 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); | 5422 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); |
5423 EnsureInitializedForIsolate(isolate, location); | 5423 EnsureInitializedForIsolate(isolate, location); |
5424 LOG_API(isolate, env); | 5424 LOG_API(isolate, env); |
5425 if (length == 0 && type != String::kUndetectableString) { | 5425 if (length == 0 && type != String::kUndetectableString) { |
5426 return String::Empty(v8_isolate); | 5426 return String::Empty(v8_isolate); |
5427 } | 5427 } |
5428 ENTER_V8(isolate); | 5428 ENTER_V8(isolate); |
5429 if (length == -1) length = StringLength(data); | 5429 if (length == -1) length = StringLength(data); |
5430 i::Handle<i::String> result = NewString( | 5430 i::Handle<i::String> result = NewString( |
5431 isolate->factory(), type, i::Vector<const Char>(data, length)); | 5431 isolate->factory(), type, i::Vector<const Char>(data, length)); |
| 5432 // We do not expect this to fail. Change this if it does. |
| 5433 CHECK(!result.is_null()); |
5432 if (type == String::kUndetectableString) { | 5434 if (type == String::kUndetectableString) { |
5433 result->MarkAsUndetectable(); | 5435 result->MarkAsUndetectable(); |
5434 } | 5436 } |
5435 return Utils::ToLocal(result); | 5437 return Utils::ToLocal(result); |
5436 } | 5438 } |
5437 | 5439 |
5438 } // anonymous namespace | 5440 } // anonymous namespace |
5439 | 5441 |
5440 | 5442 |
5441 Local<String> String::NewFromUtf8(Isolate* isolate, | 5443 Local<String> String::NewFromUtf8(Isolate* isolate, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5479 | 5481 |
5480 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { | 5482 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { |
5481 i::Handle<i::String> left_string = Utils::OpenHandle(*left); | 5483 i::Handle<i::String> left_string = Utils::OpenHandle(*left); |
5482 i::Isolate* isolate = left_string->GetIsolate(); | 5484 i::Isolate* isolate = left_string->GetIsolate(); |
5483 EnsureInitializedForIsolate(isolate, "v8::String::New()"); | 5485 EnsureInitializedForIsolate(isolate, "v8::String::New()"); |
5484 LOG_API(isolate, "String::New(char)"); | 5486 LOG_API(isolate, "String::New(char)"); |
5485 ENTER_V8(isolate); | 5487 ENTER_V8(isolate); |
5486 i::Handle<i::String> right_string = Utils::OpenHandle(*right); | 5488 i::Handle<i::String> right_string = Utils::OpenHandle(*right); |
5487 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, | 5489 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, |
5488 right_string); | 5490 right_string); |
5489 // We do not expect this to throw an exception. Change this if it does. | 5491 // We do not expect this to fail. Change this if it does. |
5490 CHECK_NOT_EMPTY_HANDLE(isolate, result); | 5492 CHECK(!result.is_null()); |
5491 return Utils::ToLocal(result); | 5493 return Utils::ToLocal(result); |
5492 } | 5494 } |
5493 | 5495 |
5494 | 5496 |
5495 static i::Handle<i::String> NewExternalStringHandle( | 5497 static i::Handle<i::String> NewExternalStringHandle( |
5496 i::Isolate* isolate, | 5498 i::Isolate* isolate, |
5497 v8::String::ExternalStringResource* resource) { | 5499 v8::String::ExternalStringResource* resource) { |
5498 return isolate->factory()->NewExternalStringFromTwoByte(resource); | 5500 i::Handle<i::String> result = |
| 5501 isolate->factory()->NewExternalStringFromTwoByte(resource); |
| 5502 // We do not expect this to fail. Change this if it does. |
| 5503 CHECK(!result.is_null()); |
| 5504 return result; |
5499 } | 5505 } |
5500 | 5506 |
5501 | 5507 |
5502 static i::Handle<i::String> NewExternalAsciiStringHandle( | 5508 static i::Handle<i::String> NewExternalAsciiStringHandle( |
5503 i::Isolate* isolate, | 5509 i::Isolate* isolate, |
5504 v8::String::ExternalAsciiStringResource* resource) { | 5510 v8::String::ExternalAsciiStringResource* resource) { |
5505 return isolate->factory()->NewExternalStringFromAscii(resource); | 5511 i::Handle<i::String> result = |
| 5512 isolate->factory()->NewExternalStringFromAscii(resource); |
| 5513 // We do not expect this to fail. Change this if it does. |
| 5514 CHECK(!result.is_null()); |
| 5515 return result; |
5506 } | 5516 } |
5507 | 5517 |
5508 | 5518 |
5509 Local<String> v8::String::NewExternal( | 5519 Local<String> v8::String::NewExternal( |
5510 Isolate* isolate, | 5520 Isolate* isolate, |
5511 v8::String::ExternalStringResource* resource) { | 5521 v8::String::ExternalStringResource* resource) { |
5512 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5522 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5513 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); | 5523 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
5514 LOG_API(i_isolate, "String::NewExternal"); | 5524 LOG_API(i_isolate, "String::NewExternal"); |
5515 ENTER_V8(i_isolate); | 5525 ENTER_V8(i_isolate); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6149 Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) { | 6159 Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) { |
6150 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6160 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6151 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); | 6161 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); |
6152 LOG_API(i_isolate, "Symbol::New()"); | 6162 LOG_API(i_isolate, "Symbol::New()"); |
6153 ENTER_V8(i_isolate); | 6163 ENTER_V8(i_isolate); |
6154 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); | 6164 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); |
6155 if (data != NULL) { | 6165 if (data != NULL) { |
6156 if (length == -1) length = i::StrLength(data); | 6166 if (length == -1) length = i::StrLength(data); |
6157 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( | 6167 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( |
6158 i::Vector<const char>(data, length)); | 6168 i::Vector<const char>(data, length)); |
| 6169 // We do not expect this to fail. Change this if it does. |
| 6170 CHECK(!name.is_null()); |
6159 result->set_name(*name); | 6171 result->set_name(*name); |
6160 } | 6172 } |
6161 return Utils::ToLocal(result); | 6173 return Utils::ToLocal(result); |
6162 } | 6174 } |
6163 | 6175 |
6164 | 6176 |
6165 Local<Private> v8::Private::New( | 6177 Local<Private> v8::Private::New( |
6166 Isolate* isolate, Local<String> name) { | 6178 Isolate* isolate, Local<String> name) { |
6167 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6179 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6168 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); | 6180 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6970 i::Isolate* isolate = i::Isolate::Current(); | 6982 i::Isolate* isolate = i::Isolate::Current(); |
6971 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6983 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
6972 const i::CodeEntry* entry = node->entry(); | 6984 const i::CodeEntry* entry = node->entry(); |
6973 if (!entry->has_name_prefix()) { | 6985 if (!entry->has_name_prefix()) { |
6974 return ToApiHandle<String>( | 6986 return ToApiHandle<String>( |
6975 isolate->factory()->InternalizeUtf8String(entry->name())); | 6987 isolate->factory()->InternalizeUtf8String(entry->name())); |
6976 } else { | 6988 } else { |
6977 i::Handle<i::String> cons = isolate->factory()->NewConsString( | 6989 i::Handle<i::String> cons = isolate->factory()->NewConsString( |
6978 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), | 6990 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), |
6979 isolate->factory()->InternalizeUtf8String(entry->name())); | 6991 isolate->factory()->InternalizeUtf8String(entry->name())); |
6980 // We do not expect this to throw an exception. Change this if it does. | 6992 // We do not expect this to fail. Change this if it does. |
6981 CHECK_NOT_EMPTY_HANDLE(isolate, cons); | 6993 CHECK(!cons.is_null()); |
6982 return ToApiHandle<String>(cons); | 6994 return ToApiHandle<String>(cons); |
6983 } | 6995 } |
6984 } | 6996 } |
6985 | 6997 |
6986 | 6998 |
6987 int CpuProfileNode::GetScriptId() const { | 6999 int CpuProfileNode::GetScriptId() const { |
6988 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 7000 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
6989 const i::CodeEntry* entry = node->entry(); | 7001 const i::CodeEntry* entry = node->entry(); |
6990 return entry->script_id(); | 7002 return entry->script_id(); |
6991 } | 7003 } |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7602 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7614 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7603 Address callback_address = | 7615 Address callback_address = |
7604 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7616 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7605 VMState<EXTERNAL> state(isolate); | 7617 VMState<EXTERNAL> state(isolate); |
7606 ExternalCallbackScope call_scope(isolate, callback_address); | 7618 ExternalCallbackScope call_scope(isolate, callback_address); |
7607 callback(info); | 7619 callback(info); |
7608 } | 7620 } |
7609 | 7621 |
7610 | 7622 |
7611 } } // namespace v8::internal | 7623 } } // namespace v8::internal |
OLD | NEW |