#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "base/debug/dump_without_crashing.h"
#include "third_party/blink/renderer/bindings/core/v8/idl_types.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/script_state_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_exception.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_element.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_event_target.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_html_link_element.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_object_builder.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_script_runner.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_window.h"
#include "third_party/blink/renderer/bindings/core/v8/window_proxy.h"
#include "third_party/blink/renderer/bindings/core/v8/window_proxy_manager.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/qualified_name.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_or_worklet_global_scope.h"
#include "third_party/blink/renderer/core/workers/worklet_global_scope.h"
#include "third_party/blink/renderer/platform/bindings/runtime_call_stats.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/v8_binding_macros.h"
#include "third_party/blink/renderer/platform/bindings/v8_object_constructor.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/traced_value.h"
#include "third_party/blink/renderer/platform/scheduler/public/event_loop.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/character_names.h"
#include "third_party/blink/renderer/platform/wtf/text/string_buffer.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
#include "third_party/blink/renderer/platform/wtf/text/unicode.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/threading.h"
namespace blink {
void V8SetReturnValue(const v8::PropertyCallbackInfo<v8::Value>& info,
const v8::PropertyDescriptor& descriptor) { … }
const int32_t kMaxInt32 = …;
const int32_t kMinInt32 = …;
const uint32_t kMaxUInt32 = …;
const int64_t kJSMaxInteger = …;
static double EnforceRange(double x,
double minimum,
double maximum,
const char* type_name,
ExceptionState& exception_state) { … }
template <typename T>
struct IntTypeNumberOfValues { … };
template <typename T>
struct IntTypeLimits { … };
template <>
struct IntTypeLimits<int8_t> { … };
template <>
struct IntTypeLimits<uint8_t> { … };
template <>
struct IntTypeLimits<int16_t> { … };
template <>
struct IntTypeLimits<uint16_t> { … };
template <typename T>
static inline T ToSmallerInt(v8::Isolate* isolate,
v8::Local<v8::Value> value,
IntegerConversionConfiguration configuration,
const char* type_name,
ExceptionState& exception_state) { … }
template <typename T>
static inline T ToSmallerUInt(v8::Isolate* isolate,
v8::Local<v8::Value> value,
IntegerConversionConfiguration configuration,
const char* type_name,
ExceptionState& exception_state) { … }
int8_t ToInt8(v8::Isolate* isolate,
v8::Local<v8::Value> value,
IntegerConversionConfiguration configuration,
ExceptionState& exception_state) { … }
uint8_t ToUInt8(v8::Isolate* isolate,
v8::Local<v8::Value> value,
IntegerConversionConfiguration configuration,
ExceptionState& exception_state) { … }
int16_t ToInt16(v8::Isolate* isolate,
v8::Local<v8::Value> value,
IntegerConversionConfiguration configuration,
ExceptionState& exception_state) { … }
uint16_t ToUInt16(v8::Isolate* isolate,
v8::Local<v8::Value> value,
IntegerConversionConfiguration configuration,
ExceptionState& exception_state) { … }
int32_t ToInt32Slow(v8::Isolate* isolate,
v8::Local<v8::Value> value,
IntegerConversionConfiguration configuration,
ExceptionState& exception_state) { … }
uint32_t ToUInt32Slow(v8::Isolate* isolate,
v8::Local<v8::Value> value,
IntegerConversionConfiguration configuration,
ExceptionState& exception_state) { … }
int64_t ToInt64Slow(v8::Isolate* isolate,
v8::Local<v8::Value> value,
IntegerConversionConfiguration configuration,
ExceptionState& exception_state) { … }
uint64_t ToUInt64Slow(v8::Isolate* isolate,
v8::Local<v8::Value> value,
IntegerConversionConfiguration configuration,
ExceptionState& exception_state) { … }
float ToRestrictedFloat(v8::Isolate* isolate,
v8::Local<v8::Value> value,
ExceptionState& exception_state) { … }
double ToDoubleSlow(v8::Isolate* isolate,
v8::Local<v8::Value> value,
ExceptionState& exception_state) { … }
double ToRestrictedDouble(v8::Isolate* isolate,
v8::Local<v8::Value> value,
ExceptionState& exception_state) { … }
static bool HasUnmatchedSurrogates(const String& string) { … }
String ReplaceUnmatchedSurrogates(String string) { … }
LocalDOMWindow* ToLocalDOMWindow(const ScriptState* script_state) { … }
ExecutionContext* ToExecutionContext(const ScriptState* script_state) { … }
LocalDOMWindow* ToLocalDOMWindow(v8::Local<v8::Context> context) { … }
LocalDOMWindow* EnteredDOMWindow(v8::Isolate* isolate) { … }
LocalDOMWindow* IncumbentDOMWindow(v8::Isolate* isolate) { … }
LocalDOMWindow* CurrentDOMWindow(v8::Isolate* isolate) { … }
ExecutionContext* ToExecutionContext(v8::Local<v8::Context> context) { … }
ExecutionContext* CurrentExecutionContext(v8::Isolate* isolate) { … }
LocalFrame* ToLocalFrameIfNotDetached(v8::Local<v8::Context> context) { … }
static ScriptState* ToScriptStateImpl(LocalFrame* frame,
DOMWrapperWorld& world) { … }
v8::Local<v8::Context> ToV8Context(ExecutionContext* context,
DOMWrapperWorld& world) { … }
v8::Local<v8::Context> ToV8Context(LocalFrame* frame, DOMWrapperWorld& world) { … }
v8::Local<v8::Context> ToV8ContextEvenIfDetached(LocalFrame* frame,
DOMWrapperWorld& world) { … }
v8::Local<v8::Context> ToV8ContextMaybeEmpty(LocalFrame* frame,
DOMWrapperWorld& world) { … }
ScriptState* ToScriptState(ExecutionContext* context, DOMWrapperWorld& world) { … }
ScriptState* ToScriptState(LocalFrame* frame, DOMWrapperWorld& world) { … }
ScriptState* ToScriptStateForMainWorld(LocalFrame* frame) { … }
ScriptState* ToScriptStateForMainWorld(ExecutionContext* context) { … }
bool IsValidEnum(const String& value,
const char* const* valid_values,
size_t length,
const String& enum_name,
ExceptionState& exception_state) { … }
bool IsValidEnum(const Vector<String>& values,
const char* const* valid_values,
size_t length,
const String& enum_name,
ExceptionState& exception_state) { … }
v8::Local<v8::Function> GetEsIteratorMethod(v8::Isolate* isolate,
v8::Local<v8::Object> object,
ExceptionState& exception_state) { … }
v8::Local<v8::Object> GetEsIteratorWithMethod(
v8::Isolate* isolate,
v8::Local<v8::Function> getter_function,
v8::Local<v8::Object> object,
ExceptionState& exception_state) { … }
bool HasCallableIteratorSymbol(v8::Isolate* isolate,
v8::Local<v8::Value> value,
ExceptionState& exception_state) { … }
v8::Isolate* ToIsolate(const LocalFrame* frame) { … }
v8::Local<v8::Value> FromJSONString(v8::Isolate* isolate,
v8::Local<v8::Context> context,
const String& stringified_json,
ExceptionState& exception_state) { … }
v8::Local<v8::Value> FromJSONString(v8::Isolate* isolate,
v8::Local<v8::Context> context,
const String& stringified_json,
TryRethrowScope&) { … }
Vector<String> GetOwnPropertyNames(v8::Isolate* isolate,
const v8::Local<v8::Object>& object,
ExceptionState& exception_state) { … }
v8::MicrotaskQueue* ToMicrotaskQueue(ExecutionContext* execution_context) { … }
v8::MicrotaskQueue* ToMicrotaskQueue(ScriptState* script_state) { … }
scheduler::EventLoop& ToEventLoop(ExecutionContext* execution_context) { … }
scheduler::EventLoop& ToEventLoop(ScriptState* script_state) { … }
bool IsInParallelAlgorithmRunnable(ExecutionContext* execution_context,
ScriptState* script_state) { … }
void ApplyContextToException(ScriptState* script_state,
v8::Local<v8::Value> exception,
const ExceptionContext& exception_context) { … }
}