OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 5419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5430 const Char* data, | 5430 const Char* data, |
5431 String::NewStringType type, | 5431 String::NewStringType type, |
5432 int length) { | 5432 int length) { |
5433 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); | 5433 i::Isolate* isolate = reinterpret_cast<internal::Isolate*>(v8_isolate); |
5434 LOG_API(isolate, env); | 5434 LOG_API(isolate, env); |
5435 if (length == 0 && type != String::kUndetectableString) { | 5435 if (length == 0 && type != String::kUndetectableString) { |
5436 return String::Empty(v8_isolate); | 5436 return String::Empty(v8_isolate); |
5437 } | 5437 } |
5438 ENTER_V8(isolate); | 5438 ENTER_V8(isolate); |
5439 if (length == -1) length = StringLength(data); | 5439 if (length == -1) length = StringLength(data); |
5440 // We do not expect this to fail. Change this if it does. | 5440 // We do not expect this to fail. Change this if it does. |
Jakob Kummerow
2015/02/10 16:00:19
nit: outdated comment
| |
5441 i::Handle<i::String> result = NewString( | 5441 EXCEPTION_PREAMBLE(isolate); |
5442 isolate->factory(), | 5442 i::Handle<i::String> result; |
5443 type, | 5443 has_pending_exception = |
5444 i::Vector<const Char>(data, length)).ToHandleChecked(); | 5444 !NewString(isolate->factory(), type, i::Vector<const Char>(data, length)) |
5445 .ToHandle(&result); | |
5446 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>()); | |
5445 if (type == String::kUndetectableString) { | 5447 if (type == String::kUndetectableString) { |
5446 result->MarkAsUndetectable(); | 5448 result->MarkAsUndetectable(); |
5447 } | 5449 } |
5448 return Utils::ToLocal(result); | 5450 return Utils::ToLocal(result); |
5449 } | 5451 } |
5450 | 5452 |
5451 } // anonymous namespace | 5453 } // anonymous namespace |
5452 | 5454 |
5453 | 5455 |
5454 Local<String> String::NewFromUtf8(Isolate* isolate, | 5456 Local<String> String::NewFromUtf8(Isolate* isolate, |
(...skipping 2285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7740 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7742 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7741 Address callback_address = | 7743 Address callback_address = |
7742 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7744 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7743 VMState<EXTERNAL> state(isolate); | 7745 VMState<EXTERNAL> state(isolate); |
7744 ExternalCallbackScope call_scope(isolate, callback_address); | 7746 ExternalCallbackScope call_scope(isolate, callback_address); |
7745 callback(info); | 7747 callback(info); |
7746 } | 7748 } |
7747 | 7749 |
7748 | 7750 |
7749 } } // namespace v8::internal | 7751 } } // namespace v8::internal |
OLD | NEW |