| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8492bc6 commit afdb362
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,13 @@ AsyncResource::AsyncResource(Isolate* isolate, | |||
| 16 | 16 | Local<Object> resource, | |
| 17 | 17 | const char* name, | |
| 18 | 18 | async_id trigger_async_id) | |
| 19 | + : AsyncResource( | ||
| 20 | + isolate, resource, std::string_view(name), trigger_async_id) {} | ||
| 21 | + | ||
| 22 | + AsyncResource::AsyncResource(Isolate* isolate, | ||
| 23 | + Local<Object> resource, | ||
| 24 | + std::string_view name, | ||
| 25 | + async_id trigger_async_id) | ||
| 19 | 26 | : env_(Environment::GetCurrent(isolate)), | |
| 20 | 27 | resource_(isolate, resource), | |
| 21 | 28 | context_frame_(isolate, async_context_frame::current(isolate)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -201,9 +201,18 @@ async_context EmitAsyncInit(Isolate* isolate, | |||
| 201 | 201 | Local<Object> resource, | |
| 202 | 202 | const char* name, | |
| 203 | 203 | async_id trigger_async_id) { | |
| 204 | + return EmitAsyncInit( | ||
| 205 | + isolate, resource, std::string_view(name), trigger_async_id); | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + async_context EmitAsyncInit(Isolate* isolate, | ||
| 209 | + Local<Object> resource, | ||
| 210 | + std::string_view name, | ||
| 211 | + async_id trigger_async_id) { | ||
| 204 | 212 | HandleScope handle_scope(isolate); | |
| 205 | 213 | Local<String> type = | |
| 206 | - String::NewFromUtf8(isolate, name, NewStringType::kInternalized) | ||
| 214 | + String::NewFromUtf8( | ||
| 215 | + isolate, name.data(), NewStringType::kInternalized, name.size()) | ||
| 207 | 216 | .ToLocalChecked(); | |
| 208 | 217 | return EmitAsyncInit(isolate, resource, type, trigger_async_id); | |
| 209 | 218 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -240,8 +240,8 @@ static void AsyncTaskScheduledWrapper(const FunctionCallbackInfo<Value>& args) { | |||
| 240 | 240 | ||
| 241 | 241 | CHECK(args[0]->IsString()); | |
| 242 | 242 | Local<String> task_name = args[0].As<String>(); | |
| 243 | - String::Value task_name_value(args.GetIsolate(), task_name); | ||
| 244 | - StringView task_name_view(*task_name_value, task_name_value.length()); | ||
| 243 | + TwoByteValue task_name_value(args.GetIsolate(), task_name); | ||
| 244 | + StringView task_name_view(task_name_value.out(), task_name_value.length()); | ||
| 245 | 245 | ||
| 246 | 246 | CHECK(args[1]->IsNumber()); | |
| 247 | 247 | int64_t task_id; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1402,6 +1402,10 @@ NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate, | |||
| 1402 | 1402 | v8::Local<v8::Object> resource, | |
| 1403 | 1403 | const char* name, | |
| 1404 | 1404 | async_id trigger_async_id = -1); | |
| 1405 | + NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate, | ||
| 1406 | + v8::Local<v8::Object> resource, | ||
| 1407 | + std::string_view name, | ||
| 1408 | + async_id trigger_async_id = -1); | ||
| 1405 | 1409 | ||
| 1406 | 1410 | NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate, | |
| 1407 | 1411 | v8::Local<v8::Object> resource, | |
@@ -1508,6 +1512,10 @@ class NODE_EXTERN AsyncResource { | |||
| 1508 | 1512 | v8::Local<v8::Object> resource, | |
| 1509 | 1513 | const char* name, | |
| 1510 | 1514 | async_id trigger_async_id = -1); | |
| 1515 | + AsyncResource(v8::Isolate* isolate, | ||
| 1516 | + v8::Local<v8::Object> resource, | ||
| 1517 | + std::string_view name, | ||
| 1518 | + async_id trigger_async_id = -1); | ||
| 1511 | 1519 | ||
| 1512 | 1520 | virtual ~AsyncResource(); | |
| 1513 | 1521 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -212,7 +212,7 @@ class ThreadSafeFunction : public node::AsyncResource { | |||
| 212 | 212 | napi_threadsafe_function_call_js call_js_cb_) | |
| 213 | 213 | : AsyncResource(env_->isolate, | |
| 214 | 214 | resource, | |
| 215 | - *v8::String::Utf8Value(env_->isolate, name)), | ||
| 215 | + node::Utf8Value(env_->isolate, name).ToStringView()), | ||
| 216 | 216 | thread_count(thread_count_), | |
| 217 | 217 | is_closing(false), | |
| 218 | 218 | dispatch_state(kDispatchIdle), | |
@@ -1150,7 +1150,7 @@ class Work : public node::AsyncResource, public node::ThreadPoolWork { | |||
| 1150 | 1150 | : AsyncResource( | |
| 1151 | 1151 | env->isolate, | |
| 1152 | 1152 | async_resource, | |
| 1153 | - *v8::String::Utf8Value(env->isolate, async_resource_name)), | ||
| 1153 | + node::Utf8Value(env->isolate, async_resource_name).ToStringView()), | ||
| 1154 | 1154 | ThreadPoolWork(env->node_env(), "node_api"), | |
| 1155 | 1155 | _env(env), | |
| 1156 | 1156 | _data(data), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -986,11 +986,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) { | |||
| 986 | 986 | size_t result = haystack_length; | |
| 987 | 987 | ||
| 988 | 988 | if (enc == UCS2) { | |
| 989 | - String::Value needle_value(isolate, needle); | ||
| 990 | - if (*needle_value == nullptr) { | ||
| 991 | - return args.GetReturnValue().Set(-1); | ||
| 992 | - } | ||
| 993 | - | ||
| 989 | + TwoByteValue needle_value(isolate, needle); | ||
| 994 | 990 | if (haystack_length < 2 || needle_value.length() < 1) { | |
| 995 | 991 | return args.GetReturnValue().Set(-1); | |
| 996 | 992 | } | |
@@ -1011,27 +1007,27 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) { | |||
| 1011 | 1007 | offset / 2, | |
| 1012 | 1008 | is_forward); | |
| 1013 | 1009 | } else { | |
| 1014 | - result = | ||
| 1015 | - nbytes::SearchString(reinterpret_cast<const uint16_t*>(haystack), | ||
| 1016 | - haystack_length / 2, | ||
| 1017 | - reinterpret_cast<const uint16_t*>(*needle_value), | ||
| 1018 | - needle_value.length(), | ||
| 1019 | - offset / 2, | ||
| 1020 | - is_forward); | ||
| 1010 | + result = nbytes::SearchString(reinterpret_cast<const uint16_t*>(haystack), | ||
| 1011 | + haystack_length / 2, | ||
| 1012 | + needle_value.out(), | ||
| 1013 | + needle_value.length(), | ||
| 1014 | + offset / 2, | ||
| 1015 | + is_forward); | ||
| 1021 | 1016 | } | |
| 1022 | 1017 | result *= 2; | |
| 1023 | 1018 | } else if (enc == UTF8) { | |
| 1024 | - String::Utf8Value needle_value(isolate, needle); | ||
| 1019 | + Utf8Value needle_value(isolate, needle); | ||
| 1025 | 1020 | if (*needle_value == nullptr) | |
| 1026 | 1021 | return args.GetReturnValue().Set(-1); | |
| 1027 | - | ||
| 1028 | - result = | ||
| 1029 | - nbytes::SearchString(reinterpret_cast<const uint8_t*>(haystack), | ||
| 1030 | - haystack_length, | ||
| 1031 | - reinterpret_cast<const uint8_t*>(*needle_value), | ||
| 1032 | - needle_length, | ||
| 1033 | - offset, | ||
| 1034 | - is_forward); | ||
| 1022 | + CHECK_GE(needle_length, needle_value.length()); | ||
| 1023 | + | ||
| 1024 | + result = nbytes::SearchString( | ||
| 1025 | + reinterpret_cast<const uint8_t*>(haystack), | ||
| 1026 | + haystack_length, | ||
| 1027 | + reinterpret_cast<const uint8_t*>(needle_value.out()), | ||
| 1028 | + needle_length, | ||
| 1029 | + offset, | ||
| 1030 | + is_forward); | ||
| 1035 | 1031 | } else if (enc == LATIN1) { | |
| 1036 | 1032 | uint8_t* needle_data = node::UncheckedMalloc<uint8_t>(needle_length); | |
| 1037 | 1033 | if (needle_data == nullptr) { | |
@@ -1316,10 +1312,10 @@ static void Btoa(const FunctionCallbackInfo<Value>& args) { | |||
| 1316 | 1312 | input->Length(), | |
| 1317 | 1313 | buffer.out()); | |
| 1318 | 1314 | } else { | |
| 1319 | - String::Value value(env->isolate(), input); | ||
| 1315 | + TwoByteValue value(env->isolate(), input); | ||
| 1320 | 1316 | MaybeStackBuffer<char> stack_buf(value.length()); | |
| 1321 | 1317 | size_t out_len = simdutf::convert_utf16_to_latin1( | |
| 1322 | - reinterpret_cast<const char16_t*>(*value), | ||
| 1318 | + reinterpret_cast<const char16_t*>(value.out()), | ||
| 1323 | 1319 | value.length(), | |
| 1324 | 1320 | stack_buf.out()); | |
| 1325 | 1321 | if (out_len == 0) { // error | |
@@ -1370,8 +1366,8 @@ static void Atob(const FunctionCallbackInfo<Value>& args) { | |||
| 1370 | 1366 | buffer.SetLength(expected_length); | |
| 1371 | 1367 | result = simdutf::base64_to_binary(data, input->Length(), buffer.out()); | |
| 1372 | 1368 | } else { // 16-bit case | |
| 1373 | - String::Value value(env->isolate(), input); | ||
| 1374 | - auto data = reinterpret_cast<const char16_t*>(*value); | ||
| 1369 | + TwoByteValue value(env->isolate(), input); | ||
| 1370 | + auto data = reinterpret_cast<const char16_t*>(value.out()); | ||
| 1375 | 1371 | size_t expected_length = | |
| 1376 | 1372 | simdutf::maximal_binary_length_from_base64(data, value.length()); | |
| 1377 | 1373 | buffer.AllocateSufficientStorage(expected_length); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1024,15 +1024,14 @@ void PerIsolateMessageListener(Local<Message> message, Local<Value> error) { | |||
| 1024 | 1024 | break; | |
| 1025 | 1025 | } | |
| 1026 | 1026 | Utf8Value filename(isolate, message->GetScriptOrigin().ResourceName()); | |
| 1027 | + Utf8Value msg(isolate, message->Get()); | ||
| 1027 | 1028 | // (filename):(line) (message) | |
| 1028 | - std::stringstream warning; | ||
| 1029 | - warning << *filename; | ||
| 1030 | - warning << ":"; | ||
| 1031 | - warning << message->GetLineNumber(env->context()).FromMaybe(-1); | ||
| 1032 | - warning << " "; | ||
| 1033 | - v8::String::Utf8Value msg(isolate, message->Get()); | ||
| 1034 | - warning << *msg; | ||
| 1035 | - USE(ProcessEmitWarningGeneric(env, warning.str().c_str(), "V8")); | ||
| 1029 | + std::string warning = | ||
| 1030 | + SPrintF("%s:%s %s", | ||
| 1031 | + filename, | ||
| 1032 | + message->GetLineNumber(env->context()).FromMaybe(-1), | ||
| 1033 | + msg); | ||
| 1034 | + USE(ProcessEmitWarningGeneric(env, warning, "V8")); | ||
| 1036 | 1035 | break; | |
| 1037 | 1036 | } | |
| 1038 | 1037 | case Isolate::MessageErrorLevel::kMessageError: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -455,8 +455,7 @@ static Maybe<std::string> ErrorToString(Isolate* isolate, | |||
| 455 | 455 | if (!maybe_str.ToLocal(&js_str)) { | |
| 456 | 456 | return Nothing<std::string>(); | |
| 457 | 457 | } | |
| 458 | - String::Utf8Value sv(isolate, js_str); | ||
| 459 | - return Just<>(std::string(*sv, sv.length())); | ||
| 458 | + return Just(Utf8Value(isolate, js_str).ToString()); | ||
| 460 | 459 | } | |
| 461 | 460 | ||
| 462 | 461 | static void PrintEmptyJavaScriptStack(JSONWriter* writer) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1508,8 +1508,7 @@ void DatabaseSync::CreateSession(const FunctionCallbackInfo<Value>& args) { | |||
| 1508 | 1508 | } | |
| 1509 | 1509 | ||
| 1510 | 1510 | if (table_value->IsString()) { | |
| 1511 | - String::Utf8Value str(env->isolate(), table_value); | ||
| 1512 | - table = *str; | ||
| 1511 | + table = Utf8Value(env->isolate(), table_value).ToString(); | ||
| 1513 | 1512 | } else { | |
| 1514 | 1513 | THROW_ERR_INVALID_ARG_TYPE( | |
| 1515 | 1514 | env->isolate(), "The \"options.table\" argument must be a string."); | |
@@ -1529,8 +1528,7 @@ void DatabaseSync::CreateSession(const FunctionCallbackInfo<Value>& args) { | |||
| 1529 | 1528 | return; | |
| 1530 | 1529 | } | |
| 1531 | 1530 | if (db_value->IsString()) { | |
| 1532 | - String::Utf8Value str(env->isolate(), db_value); | ||
| 1533 | - db_name = std::string(*str); | ||
| 1531 | + db_name = Utf8Value(env->isolate(), db_value).ToString(); | ||
| 1534 | 1532 | } else { | |
| 1535 | 1533 | THROW_ERR_INVALID_ARG_TYPE( | |
| 1536 | 1534 | env->isolate(), "The \"options.db\" argument must be a string."); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -242,8 +242,8 @@ void UpdateHeapCodeStatisticsBuffer(const FunctionCallbackInfo<Value>& args) { | |||
| 242 | 242 | ||
| 243 | 243 | void SetFlagsFromString(const FunctionCallbackInfo<Value>& args) { | |
| 244 | 244 | CHECK(args[0]->IsString()); | |
| 245 | - String::Utf8Value flags(args.GetIsolate(), args[0]); | ||
| 246 | - V8::SetFlagsFromString(*flags, static_cast<size_t>(flags.length())); | ||
| 245 | + Utf8Value flags(args.GetIsolate(), args[0]); | ||
| 246 | + V8::SetFlagsFromString(flags.out(), flags.length()); | ||
| 247 | 247 | } | |
| 248 | 248 | ||
| 249 | 249 | void StartCpuProfile(const FunctionCallbackInfo<Value>& args) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments