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 5385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5396 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); | 5396 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); |
5397 EnsureInitializedForIsolate(isolate, location); | 5397 EnsureInitializedForIsolate(isolate, location); |
5398 LOG_API(isolate, env); | 5398 LOG_API(isolate, env); |
5399 if (length == 0 && type != String::kUndetectableString) { | 5399 if (length == 0 && type != String::kUndetectableString) { |
5400 return String::Empty(v8_isolate); | 5400 return String::Empty(v8_isolate); |
5401 } | 5401 } |
5402 ENTER_V8(isolate); | 5402 ENTER_V8(isolate); |
5403 if (length == -1) length = StringLength(data); | 5403 if (length == -1) length = StringLength(data); |
5404 i::Handle<i::String> result = NewString( | 5404 i::Handle<i::String> result = NewString( |
5405 isolate->factory(), type, i::Vector<const Char>(data, length)); | 5405 isolate->factory(), type, i::Vector<const Char>(data, length)); |
5406 // We do not expect this to fail. Change this if it does. | |
5407 CHECK(!result.is_null()); | |
5408 if (type == String::kUndetectableString) { | 5406 if (type == String::kUndetectableString) { |
5409 result->MarkAsUndetectable(); | 5407 result->MarkAsUndetectable(); |
5410 } | 5408 } |
5411 return Utils::ToLocal(result); | 5409 return Utils::ToLocal(result); |
5412 } | 5410 } |
5413 | 5411 |
5414 } // anonymous namespace | 5412 } // anonymous namespace |
5415 | 5413 |
5416 | 5414 |
5417 Local<String> String::NewFromUtf8(Isolate* isolate, | 5415 Local<String> String::NewFromUtf8(Isolate* isolate, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5455 | 5453 |
5456 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { | 5454 Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) { |
5457 i::Handle<i::String> left_string = Utils::OpenHandle(*left); | 5455 i::Handle<i::String> left_string = Utils::OpenHandle(*left); |
5458 i::Isolate* isolate = left_string->GetIsolate(); | 5456 i::Isolate* isolate = left_string->GetIsolate(); |
5459 EnsureInitializedForIsolate(isolate, "v8::String::New()"); | 5457 EnsureInitializedForIsolate(isolate, "v8::String::New()"); |
5460 LOG_API(isolate, "String::New(char)"); | 5458 LOG_API(isolate, "String::New(char)"); |
5461 ENTER_V8(isolate); | 5459 ENTER_V8(isolate); |
5462 i::Handle<i::String> right_string = Utils::OpenHandle(*right); | 5460 i::Handle<i::String> right_string = Utils::OpenHandle(*right); |
5463 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, | 5461 i::Handle<i::String> result = isolate->factory()->NewConsString(left_string, |
5464 right_string); | 5462 right_string); |
5465 // We do not expect this to fail. Change this if it does. | 5463 // We do not expect this to throw an exception. Change this if it does. |
5466 CHECK(!result.is_null()); | 5464 CHECK_NOT_EMPTY_HANDLE(isolate, result); |
5467 return Utils::ToLocal(result); | 5465 return Utils::ToLocal(result); |
5468 } | 5466 } |
5469 | 5467 |
5470 | 5468 |
5471 static i::Handle<i::String> NewExternalStringHandle( | 5469 static i::Handle<i::String> NewExternalStringHandle( |
5472 i::Isolate* isolate, | 5470 i::Isolate* isolate, |
5473 v8::String::ExternalStringResource* resource) { | 5471 v8::String::ExternalStringResource* resource) { |
5474 i::Handle<i::String> result = | 5472 return isolate->factory()->NewExternalStringFromTwoByte(resource); |
5475 isolate->factory()->NewExternalStringFromTwoByte(resource); | |
5476 // We do not expect this to fail. Change this if it does. | |
5477 CHECK(!result.is_null()); | |
5478 return result; | |
5479 } | 5473 } |
5480 | 5474 |
5481 | 5475 |
5482 static i::Handle<i::String> NewExternalAsciiStringHandle( | 5476 static i::Handle<i::String> NewExternalAsciiStringHandle( |
5483 i::Isolate* isolate, | 5477 i::Isolate* isolate, |
5484 v8::String::ExternalAsciiStringResource* resource) { | 5478 v8::String::ExternalAsciiStringResource* resource) { |
5485 i::Handle<i::String> result = | 5479 return isolate->factory()->NewExternalStringFromAscii(resource); |
5486 isolate->factory()->NewExternalStringFromAscii(resource); | |
5487 // We do not expect this to fail. Change this if it does. | |
5488 CHECK(!result.is_null()); | |
5489 return result; | |
5490 } | 5480 } |
5491 | 5481 |
5492 | 5482 |
5493 Local<String> v8::String::NewExternal( | 5483 Local<String> v8::String::NewExternal( |
5494 Isolate* isolate, | 5484 Isolate* isolate, |
5495 v8::String::ExternalStringResource* resource) { | 5485 v8::String::ExternalStringResource* resource) { |
5496 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5486 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
5497 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); | 5487 EnsureInitializedForIsolate(i_isolate, "v8::String::NewExternal()"); |
5498 LOG_API(i_isolate, "String::NewExternal"); | 5488 LOG_API(i_isolate, "String::NewExternal"); |
5499 ENTER_V8(i_isolate); | 5489 ENTER_V8(i_isolate); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6133 Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) { | 6123 Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) { |
6134 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6124 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6135 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); | 6125 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); |
6136 LOG_API(i_isolate, "Symbol::New()"); | 6126 LOG_API(i_isolate, "Symbol::New()"); |
6137 ENTER_V8(i_isolate); | 6127 ENTER_V8(i_isolate); |
6138 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); | 6128 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); |
6139 if (data != NULL) { | 6129 if (data != NULL) { |
6140 if (length == -1) length = i::StrLength(data); | 6130 if (length == -1) length = i::StrLength(data); |
6141 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( | 6131 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( |
6142 i::Vector<const char>(data, length)); | 6132 i::Vector<const char>(data, length)); |
6143 // We do not expect this to fail. Change this if it does. | |
6144 CHECK(!name.is_null()); | |
6145 result->set_name(*name); | 6133 result->set_name(*name); |
6146 } | 6134 } |
6147 return Utils::ToLocal(result); | 6135 return Utils::ToLocal(result); |
6148 } | 6136 } |
6149 | 6137 |
6150 | 6138 |
6151 Local<Private> v8::Private::New( | 6139 Local<Private> v8::Private::New( |
6152 Isolate* isolate, Local<String> name) { | 6140 Isolate* isolate, Local<String> name) { |
6153 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6141 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6154 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); | 6142 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6956 i::Isolate* isolate = i::Isolate::Current(); | 6944 i::Isolate* isolate = i::Isolate::Current(); |
6957 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6945 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
6958 const i::CodeEntry* entry = node->entry(); | 6946 const i::CodeEntry* entry = node->entry(); |
6959 if (!entry->has_name_prefix()) { | 6947 if (!entry->has_name_prefix()) { |
6960 return ToApiHandle<String>( | 6948 return ToApiHandle<String>( |
6961 isolate->factory()->InternalizeUtf8String(entry->name())); | 6949 isolate->factory()->InternalizeUtf8String(entry->name())); |
6962 } else { | 6950 } else { |
6963 i::Handle<i::String> cons = isolate->factory()->NewConsString( | 6951 i::Handle<i::String> cons = isolate->factory()->NewConsString( |
6964 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), | 6952 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), |
6965 isolate->factory()->InternalizeUtf8String(entry->name())); | 6953 isolate->factory()->InternalizeUtf8String(entry->name())); |
6966 // We do not expect this to fail. Change this if it does. | 6954 // We do not expect this to throw an exception. Change this if it does. |
6967 CHECK(!cons.is_null()); | 6955 CHECK_NOT_EMPTY_HANDLE(isolate, cons); |
6968 return ToApiHandle<String>(cons); | 6956 return ToApiHandle<String>(cons); |
6969 } | 6957 } |
6970 } | 6958 } |
6971 | 6959 |
6972 | 6960 |
6973 int CpuProfileNode::GetScriptId() const { | 6961 int CpuProfileNode::GetScriptId() const { |
6974 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 6962 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
6975 const i::CodeEntry* entry = node->entry(); | 6963 const i::CodeEntry* entry = node->entry(); |
6976 return entry->script_id(); | 6964 return entry->script_id(); |
6977 } | 6965 } |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7588 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7576 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7589 Address callback_address = | 7577 Address callback_address = |
7590 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7578 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7591 VMState<EXTERNAL> state(isolate); | 7579 VMState<EXTERNAL> state(isolate); |
7592 ExternalCallbackScope call_scope(isolate, callback_address); | 7580 ExternalCallbackScope call_scope(isolate, callback_address); |
7593 callback(info); | 7581 callback(info); |
7594 } | 7582 } |
7595 | 7583 |
7596 | 7584 |
7597 } } // namespace v8::internal | 7585 } } // namespace v8::internal |
OLD | NEW |