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 5413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5424 | 5424 |
5425 | 5425 |
5426 template<typename Char> | 5426 template<typename Char> |
5427 inline Local<String> NewString(Isolate* v8_isolate, | 5427 inline Local<String> NewString(Isolate* v8_isolate, |
5428 const char* location, | 5428 const char* location, |
5429 const char* env, | 5429 const char* env, |
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 ON_BAILOUT(isolate, location, return Local<String>()); |
5434 LOG_API(isolate, env); | 5435 LOG_API(isolate, env); |
5435 if (length == 0) { | 5436 if (length == 0) { |
5436 return String::Empty(v8_isolate); | 5437 return String::Empty(v8_isolate); |
5437 } | 5438 } |
5438 ENTER_V8(isolate); | 5439 ENTER_V8(isolate); |
5439 if (length == -1) length = StringLength(data); | 5440 if (length == -1) length = StringLength(data); |
5440 // We do not expect this to fail. Change this if it does. | 5441 EXCEPTION_PREAMBLE(isolate); |
5441 i::Handle<i::String> result = NewString( | 5442 i::Handle<i::String> result; |
5442 isolate->factory(), | 5443 has_pending_exception = |
5443 type, | 5444 !NewString(isolate->factory(), type, i::Vector<const Char>(data, length)) |
5444 i::Vector<const Char>(data, length)).ToHandleChecked(); | 5445 .ToHandle(&result); |
| 5446 EXCEPTION_BAILOUT_CHECK(isolate, Local<String>()); |
5445 return Utils::ToLocal(result); | 5447 return Utils::ToLocal(result); |
5446 } | 5448 } |
5447 | 5449 |
5448 } // anonymous namespace | 5450 } // anonymous namespace |
5449 | 5451 |
5450 | 5452 |
5451 Local<String> String::NewFromUtf8(Isolate* isolate, | 5453 Local<String> String::NewFromUtf8(Isolate* isolate, |
5452 const char* data, | 5454 const char* data, |
5453 NewStringType type, | 5455 NewStringType type, |
5454 int length) { | 5456 int length) { |
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7737 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7739 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7738 Address callback_address = | 7740 Address callback_address = |
7739 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7741 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7740 VMState<EXTERNAL> state(isolate); | 7742 VMState<EXTERNAL> state(isolate); |
7741 ExternalCallbackScope call_scope(isolate, callback_address); | 7743 ExternalCallbackScope call_scope(isolate, callback_address); |
7742 callback(info); | 7744 callback(info); |
7743 } | 7745 } |
7744 | 7746 |
7745 | 7747 |
7746 } } // namespace v8::internal | 7748 } } // namespace v8::internal |
OLD | NEW |