v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
runtime-intl.cc
Go to the documentation of this file.
1// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_INTL_SUPPORT
6#error Internationalization is expected to be enabled.
7#endif // V8_INTL_SUPPORT
8
9#include <cmath>
10#include <memory>
11
21
22namespace v8 {
23namespace internal {
24
25// ecma402 #sec-formatlist
26RUNTIME_FUNCTION(Runtime_FormatList) {
27 HandleScope scope(isolate);
28 DCHECK_EQ(2, args.length());
29 DirectHandle<JSListFormat> list_format = args.at<JSListFormat>(0);
32 isolate, JSListFormat::FormatList(isolate, list_format, list));
33}
34
35// ecma402 #sec-formatlisttoparts
36RUNTIME_FUNCTION(Runtime_FormatListToParts) {
37 HandleScope scope(isolate);
38 DCHECK_EQ(2, args.length());
39 DirectHandle<JSListFormat> list_format = args.at<JSListFormat>(0);
42 isolate, JSListFormat::FormatListToParts(isolate, list_format, list));
43}
44
45RUNTIME_FUNCTION(Runtime_StringToLowerCaseIntl) {
46 // When this is called from Wasm code, clear the "thread in wasm" flag,
47 // which is important in case any GC needs to happen.
48 // TODO(40192807): Find a better fix, likely by replacing the global flag.
49 SaveAndClearThreadInWasmFlag clear_wasm_flag(isolate);
50
51 HandleScope scope(isolate);
52 DCHECK_EQ(args.length(), 1);
53 Handle<String> s = args.at<String>(0);
54 s = String::Flatten(isolate, s);
56}
57
58RUNTIME_FUNCTION(Runtime_StringToUpperCaseIntl) {
59 // When this is called from Wasm code, clear the "thread in wasm" flag,
60 // which is important in case any GC needs to happen.
61 // TODO(40192807): Find a better fix, likely by replacing the global flag.
62 SaveAndClearThreadInWasmFlag clear_wasm_flag(isolate);
63
64 HandleScope scope(isolate);
65 DCHECK_EQ(args.length(), 1);
66 Handle<String> s = args.at<String>(0);
67 s = String::Flatten(isolate, s);
69}
70
71RUNTIME_FUNCTION(Runtime_StringToLocaleLowerCase) {
72 // When this is called from Wasm code, clear the "thread in wasm" flag,
73 // which is important in case any GC needs to happen.
74 // TODO(40192807): Find a better fix, likely by replacing the global flag.
75 SaveAndClearThreadInWasmFlag clear_wasm_flag(isolate);
76
77 HandleScope scope(isolate);
78 DCHECK_EQ(args.length(), 2);
80 DirectHandle<Object> locale = args.at<Object>(1);
81
83
85 isolate, Intl::StringLocaleConvertCase(isolate, s, false, locale));
86}
87
88} // namespace internal
89} // namespace v8
@ kStringToLocaleLowerCase
Definition v8-isolate.h:533
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > StringLocaleConvertCase(Isolate *isolate, DirectHandle< String > s, bool is_upper, DirectHandle< Object > locales)
static V8_WARN_UNUSED_RESULT MaybeHandle< String > ConvertToLower(Isolate *isolate, DirectHandle< String > s)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > ConvertToUpper(Isolate *isolate, DirectHandle< String > s)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > FormatList(Isolate *isolate, DirectHandle< JSListFormat > format_holder, DirectHandle< FixedArray > list)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSArray > FormatListToParts(Isolate *isolate, DirectHandle< JSListFormat > format_holder, DirectHandle< FixedArray > list)
static V8_INLINE HandleType< String > Flatten(Isolate *isolate, HandleType< T > string, AllocationType allocation=AllocationType::kYoung)
#define RUNTIME_FUNCTION(Name)
Definition arguments.h:162
#define RETURN_RESULT_OR_FAILURE(isolate, call)
Definition isolate.h:264
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
#define DCHECK_EQ(v1, v2)
Definition logging.h:485