ClearScript/V8/V8Patch.txt

667 строки
26 KiB
Plaintext

diff --git a/BUILD.gn b/BUILD.gn
index 83082271b8..778c555275 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1100,7 +1100,7 @@ config("toolchain") {
visibility = [ "./*" ]
defines = []
- cflags = []
+ cflags = [ "-Wno-invalid-offsetof", "-Wno-unused-result", "-Wno-deprecated-copy-with-user-provided-copy", "-Wno-extra-semi", "-Wno-c++98-compat-extra-semi" ]
ldflags = []
if (v8_current_cpu == "arm") {
diff --git a/include/cppgc/internal/write-barrier.h b/include/cppgc/internal/write-barrier.h
index d68269dd4f..4d4fde6873 100644
--- a/include/cppgc/internal/write-barrier.h
+++ b/include/cppgc/internal/write-barrier.h
@@ -92,7 +92,7 @@ class V8_EXPORT WriteBarrier final {
#else // !CPPGC_YOUNG_GENERATION
template <GenerationalBarrierType>
static V8_INLINE void GenerationalBarrier(const Params& params,
- const void* slot){};
+ const void* slot){}
#endif // CPPGC_YOUNG_GENERATION
#if V8_ENABLE_CHECKS
diff --git a/include/v8-initialization.h b/include/v8-initialization.h
index 224ae0dc6b..ec17656b4b 100644
--- a/include/v8-initialization.h
+++ b/include/v8-initialization.h
@@ -139,6 +139,7 @@ class V8_EXPORT V8 {
* of the data file has to be provided.
*/
static bool InitializeICU(const char* icu_data_file = nullptr);
+ static bool InitializeICU(const char* icu_data_ptr, size_t size);
/**
* Initialize the ICU library bundled with V8. The embedder should only
diff --git a/include/v8-template.h b/include/v8-template.h
index 669012a981..b19ea9c824 100644
--- a/include/v8-template.h
+++ b/include/v8-template.h
@@ -937,6 +937,9 @@ class V8_EXPORT ObjectTemplate : public Template {
*/
void SetImmutableProto();
+ bool IsHostDelegate() const;
+ void SetHostDelegate();
+
/**
* Support for TC39 "dynamic code brand checks" proposal.
*
diff --git a/src/api/api-natives.cc b/src/api/api-natives.cc
index 562b7849b4..f585106ffd 100644
--- a/src/api/api-natives.cc
+++ b/src/api/api-natives.cc
@@ -443,6 +443,9 @@ MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
if (info->immutable_proto()) {
JSObject::SetImmutableProto(object);
}
+ else if (info->host_delegate()) {
+ JSObject::SetHostDelegate(object);
+ }
if (!is_prototype) {
// Keep prototypes in slow-mode. Let them be lazily turned fast later on.
// TODO(dcarney): is this necessary?
diff --git a/src/api/api.cc b/src/api/api.cc
index 353fa739d8..61974a4129 100644
--- a/src/api/api.cc
+++ b/src/api/api.cc
@@ -1940,6 +1940,17 @@ void ObjectTemplate::SetImmutableProto() {
self->set_immutable_proto(true);
}
+bool ObjectTemplate::IsHostDelegate() const {
+ return Utils::OpenHandle(this)->host_delegate();
+}
+
+void ObjectTemplate::SetHostDelegate() {
+ auto self = Utils::OpenHandle(this);
+ i::Isolate* isolate = self->GetIsolate();
+ ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
+ self->set_host_delegate(true);
+}
+
bool ObjectTemplate::IsCodeLike() const {
return Utils::OpenHandle(this)->code_like();
}
@@ -6215,6 +6226,10 @@ bool v8::V8::InitializeICU(const char* icu_data_file) {
return i::InitializeICU(icu_data_file);
}
+bool v8::V8::InitializeICU(const char* icu_data_ptr, size_t size) {
+ return i::InitializeICU(icu_data_ptr, size);
+}
+
bool v8::V8::InitializeICUDefaultLocation(const char* exec_path,
const char* icu_data_file) {
return i::InitializeICUDefaultLocation(exec_path, icu_data_file);
diff --git a/src/ast/ast.cc b/src/ast/ast.cc
index 97db02225f..d413a93530 100644
--- a/src/ast/ast.cc
+++ b/src/ast/ast.cc
@@ -884,8 +884,11 @@ static bool MatchLiteralCompareTypeof(Expression* left, Token::Value op,
return false;
}
+static bool disable_literal_compare_typeof_detection = true;
+
bool CompareOperation::IsLiteralCompareTypeof(Expression** expr,
Literal** literal) {
+ if (disable_literal_compare_typeof_detection) return false;
return MatchLiteralCompareTypeof(left_, op(), right_, expr, literal) ||
MatchLiteralCompareTypeof(right_, op(), left_, expr, literal);
}
diff --git a/src/base/platform/platform.h b/src/base/platform/platform.h
index 45ecfb3e3e..ab28df6210 100644
--- a/src/base/platform/platform.h
+++ b/src/base/platform/platform.h
@@ -51,6 +51,8 @@
#include <sanitizer/asan_interface.h>
#endif // V8_USE_ADDRESS_SANITIZER
+#define V8_NO_FAST_TLS
+
#ifndef V8_NO_FAST_TLS
#if V8_CC_MSVC && V8_HOST_ARCH_IA32
// __readfsdword is supposed to be declared in intrin.h but it is missing from
diff --git a/src/builtins/builtins-async-module.cc b/src/builtins/builtins-async-module.cc
index 417e6f1dfa..108dc20972 100644
--- a/src/builtins/builtins-async-module.cc
+++ b/src/builtins/builtins-async-module.cc
@@ -15,7 +15,8 @@ BUILTIN(CallAsyncModuleFulfilled) {
SourceTextModule::cast(isolate->context().get(
SourceTextModule::ExecuteAsyncModuleContextSlots::kModule)),
isolate);
- if (SourceTextModule::AsyncModuleExecutionFulfilled(isolate, module)
+ Handle<Object> result(args.at(1));
+ if (SourceTextModule::AsyncModuleExecutionFulfilled(isolate, module, result)
.IsNothing()) {
// The evaluation of async module can not throwing a JavaScript observable
// exception.
diff --git a/src/codegen/code-stub-assembler.cc b/src/codegen/code-stub-assembler.cc
index 9a12cfdd9d..a1388f5590 100644
--- a/src/codegen/code-stub-assembler.cc
+++ b/src/codegen/code-stub-assembler.cc
@@ -1843,6 +1843,10 @@ TNode<Uint32T> CodeStubAssembler::LoadMapBitField3(TNode<Map> map) {
return LoadObjectField<Uint32T>(map, Map::kBitField3Offset);
}
+TNode<Uint32T> CodeStubAssembler::LoadMapHostBitField(TNode<Map> map) {
+ return LoadObjectField<Uint32T>(map, Map::kHostBitFieldOffset);
+}
+
TNode<Uint16T> CodeStubAssembler::LoadMapInstanceType(TNode<Map> map) {
return LoadObjectField<Uint16T>(map, Map::kInstanceTypeOffset);
}
@@ -13638,6 +13642,11 @@ TNode<String> CodeStubAssembler::Typeof(TNode<Object> value) {
GotoIf(InstanceTypeEqual(instance_type, ODDBALL_TYPE), &if_oddball);
+ Label resume_default(this);
+ GotoIfNot(Word32And(LoadMapBitField(map), Int32Constant(Map::Bits1::HasNamedInterceptorBit::kMask)), &resume_default);
+ Branch(Word32And(LoadMapHostBitField(map), Int32Constant(Map::HostBits::IsHostDelegateBit::kMask)), &return_function, &return_object);
+ BIND(&resume_default);
+
TNode<Int32T> callable_or_undetectable_mask =
Word32And(LoadMapBitField(map),
Int32Constant(Map::Bits1::IsCallableBit::kMask |
diff --git a/src/codegen/code-stub-assembler.h b/src/codegen/code-stub-assembler.h
index 5c89a2ac9d..23aebfdd17 100644
--- a/src/codegen/code-stub-assembler.h
+++ b/src/codegen/code-stub-assembler.h
@@ -1406,6 +1406,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<Int32T> LoadMapBitField2(TNode<Map> map);
// Load bit field 3 of a map.
TNode<Uint32T> LoadMapBitField3(TNode<Map> map);
+ // Load host bit field of a map.
+ TNode<Uint32T> LoadMapHostBitField(TNode<Map> map);
// Load the instance type of a map.
TNode<Uint16T> LoadMapInstanceType(TNode<Map> map);
// Load the ElementsKind of a map.
diff --git a/src/common/globals.h b/src/common/globals.h
index ab9d3bb1ca..f1b94ac92e 100644
--- a/src/common/globals.h
+++ b/src/common/globals.h
@@ -196,7 +196,7 @@ using CodeT = Code;
//
#if V8_HAS_PTHREAD_JIT_WRITE_PROTECT && \
!(defined(V8_COMPRESS_POINTERS) && !defined(V8_EXTERNAL_CODE_SPACE))
-#define V8_HEAP_USE_PTHREAD_JIT_WRITE_PROTECT true
+#define V8_HEAP_USE_PTHREAD_JIT_WRITE_PROTECT false
#else
#define V8_HEAP_USE_PTHREAD_JIT_WRITE_PROTECT false
#endif
diff --git a/src/diagnostics/unwinding-info-win64.cc b/src/diagnostics/unwinding-info-win64.cc
index 4a70a28478..420eff5a33 100644
--- a/src/diagnostics/unwinding-info-win64.cc
+++ b/src/diagnostics/unwinding-info-win64.cc
@@ -463,6 +463,14 @@ void InitUnwindingRecord(Record* record, size_t code_size_in_bytes) {
namespace {
V8_DECLARE_ONCE(load_ntdll_unwinding_functions_once);
+
+#if defined(V8_OS_WIN_X64)
+static decltype(
+ &::RtlAddFunctionTable) add_function_table_func = nullptr;
+static decltype(
+ &::RtlDeleteFunctionTable) delete_function_table_func = nullptr;
+#endif // V8_OS_WIN_X64
+
static decltype(
&::RtlAddGrowableFunctionTable) add_growable_function_table_func = nullptr;
static decltype(
@@ -470,6 +478,19 @@ static decltype(
nullptr;
void LoadNtdllUnwindingFunctionsOnce() {
+
+#if defined(V8_OS_WIN_X64)
+ HMODULE kernel32_module =
+ LoadLibraryEx(L"kernel32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
+ DCHECK_NOT_NULL(kernel32_module);
+ add_function_table_func =
+ reinterpret_cast<decltype(&::RtlAddFunctionTable)>(
+ ::GetProcAddress(kernel32_module, "RtlAddFunctionTable"));
+ delete_function_table_func =
+ reinterpret_cast<decltype(&::RtlDeleteFunctionTable)>(
+ ::GetProcAddress(kernel32_module, "RtlDeleteFunctionTable"));
+#endif // V8_OS_WIN_X64
+
// Load functions from the ntdll.dll module.
HMODULE ntdll_module =
LoadLibraryEx(L"ntdll.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
@@ -492,6 +513,21 @@ void LoadNtdllUnwindingFunctions() {
&LoadNtdllUnwindingFunctionsOnce);
}
+#if defined(V8_OS_WIN_X64)
+BOOLEAN AddFunctionTable(PRUNTIME_FUNCTION FunctionTable,
+ DWORD EntryCount,
+ DWORD64 BaseAddress) {
+ LoadNtdllUnwindingFunctions();
+ DCHECK_NOT_NULL(add_function_table_func);
+ return add_function_table_func(FunctionTable, EntryCount, BaseAddress);
+}
+BOOLEAN DeleteFunctionTable(PRUNTIME_FUNCTION FunctionTable) {
+ LoadNtdllUnwindingFunctions();
+ DCHECK_NOT_NULL(delete_function_table_func);
+ return delete_function_table_func(FunctionTable);
+}
+#endif // V8_OS_WIN_X64
+
bool AddGrowableFunctionTable(PVOID* DynamicTable,
PRUNTIME_FUNCTION FunctionTable, DWORD EntryCount,
DWORD MaximumEntryCount, ULONG_PTR RangeBase,
@@ -543,7 +579,7 @@ void RegisterNonABICompliantCodeRange(void* start, size_t size_in_bytes) {
ExceptionHandlerRecord* record = new (start) ExceptionHandlerRecord();
InitUnwindingRecord(record, size_in_bytes);
- CHECK(::RtlAddFunctionTable(record->runtime_function,
+ CHECK(AddFunctionTable(record->runtime_function,
kDefaultRuntimeFunctionCount,
reinterpret_cast<DWORD64>(start)));
@@ -581,7 +617,7 @@ void UnregisterNonABICompliantCodeRange(void* start) {
if (unhandled_exception_callback_g) {
ExceptionHandlerRecord* record =
reinterpret_cast<ExceptionHandlerRecord*>(start);
- CHECK(::RtlDeleteFunctionTable(record->runtime_function));
+ CHECK(DeleteFunctionTable(record->runtime_function));
// Unprotect reserved page.
DWORD old_protect;
diff --git a/src/execution/isolate.h b/src/execution/isolate.h
index 66735c9283..e12f0ad996 100644
--- a/src/execution/isolate.h
+++ b/src/execution/isolate.h
@@ -661,7 +661,6 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
// Returns the isolate inside which the current thread is running.
V8_INLINE static Isolate* Current() {
Isolate* isolate = TryGetCurrent();
- DCHECK_NOT_NULL(isolate);
return isolate;
}
diff --git a/src/execution/stack-guard.cc b/src/execution/stack-guard.cc
index 31d9b52c82..141b9aceb5 100644
--- a/src/execution/stack-guard.cc
+++ b/src/execution/stack-guard.cc
@@ -218,8 +218,10 @@ void StackGuard::FreeThreadResources() {
void StackGuard::ThreadLocal::Initialize(Isolate* isolate,
const ExecutionAccess& lock) {
const uintptr_t kLimitSize = FLAG_stack_size * KB;
- DCHECK_GT(GetCurrentStackPosition(), kLimitSize);
uintptr_t limit = GetCurrentStackPosition() - kLimitSize;
+ if (GetCurrentStackPosition() < kLimitSize) {
+ limit = 0;
+ }
real_jslimit_ = SimulatorStack::JsLimitFromCLimit(isolate, limit);
set_jslimit(SimulatorStack::JsLimitFromCLimit(isolate, limit));
real_climit_ = limit;
diff --git a/src/heap/factory.cc b/src/heap/factory.cc
index 292ee8b116..723ce323a1 100644
--- a/src/heap/factory.cc
+++ b/src/heap/factory.cc
@@ -2039,6 +2039,7 @@ Map Factory::InitializeMap(Map map, InstanceType type, int instance_size,
Map::Bits3::ConstructionCounterBits::encode(Map::kNoSlackTracking) |
Map::Bits3::IsExtensibleBit::encode(true);
map.set_bit_field3(bit_field3);
+ map.set_host_bit_field(0);
map.set_instance_type(type);
ReadOnlyRoots ro_roots(roots);
HeapObject raw_null_value = ro_roots.null_value();
diff --git a/src/heap/setup-heap-internal.cc b/src/heap/setup-heap-internal.cc
index 5666c5834e..851dddb224 100644
--- a/src/heap/setup-heap-internal.cc
+++ b/src/heap/setup-heap-internal.cc
@@ -188,6 +188,7 @@ AllocationResult Heap::AllocatePartialMap(InstanceType instance_type,
Map::Bits3::OwnsDescriptorsBit::encode(true) |
Map::Bits3::ConstructionCounterBits::encode(Map::kNoSlackTracking);
map.set_bit_field3(bit_field3);
+ map.set_host_bit_field(0);
DCHECK(!map.is_in_retained_map_list());
map.clear_padding();
map.set_elements_kind(TERMINAL_FAST_ELEMENTS_KIND);
diff --git a/src/init/icu_util.cc b/src/init/icu_util.cc
index 67d349557c..49ffb52386 100644
--- a/src/init/icu_util.cc
+++ b/src/init/icu_util.cc
@@ -98,6 +98,26 @@ bool InitializeICU(const char* icu_data_file) {
#endif
}
+bool InitializeICU(const char* icu_data_ptr, size_t size) {
+#if !defined(V8_INTL_SUPPORT)
+ return true;
+#else
+#if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC
+ return true;
+#elif ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
+ if (!icu_data_ptr) return false;
+ if (g_icu_data_ptr) return true;
+ g_icu_data_ptr = new char[size];
+ memcpy(g_icu_data_ptr, icu_data_ptr, size);
+ atexit(free_icu_data_ptr);
+ UErrorCode err = U_ZERO_ERROR;
+ udata_setCommonData(reinterpret_cast<void*>(g_icu_data_ptr), &err);
+ udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
+ return err == U_ZERO_ERROR;
+#endif
+#endif
+}
+
#undef ICU_UTIL_DATA_FILE
#undef ICU_UTIL_DATA_STATIC
diff --git a/src/init/icu_util.h b/src/init/icu_util.h
index e127e75f10..b0e4bd2d68 100644
--- a/src/init/icu_util.h
+++ b/src/init/icu_util.h
@@ -5,6 +5,8 @@
#ifndef V8_INIT_ICU_UTIL_H_
#define V8_INIT_ICU_UTIL_H_
+#include <stddef.h>
+
namespace v8 {
namespace internal {
@@ -12,6 +14,7 @@ namespace internal {
// Call this function to load ICU's data tables for the current process. This
// function should be called before ICU is used.
bool InitializeICU(const char* icu_data_file);
+bool InitializeICU(const char* icu_data_ptr, size_t size);
// Like above, but using the default icudt[lb].dat location if icu_data_file is
// not specified.
diff --git a/src/init/v8.cc b/src/init/v8.cc
index 18fab17246..2519dd93d3 100644
--- a/src/init/v8.cc
+++ b/src/init/v8.cc
@@ -93,7 +93,6 @@ V8_DECLARE_ONCE(init_snapshot_once);
void V8::InitializePlatform(v8::Platform* platform) {
AdvanceStartupState(V8StartupState::kPlatformInitializing);
- CHECK(!platform_);
CHECK_NOT_NULL(platform);
platform_ = platform;
v8::base::SetPrintStackTrace(platform_->GetStackTracePrinter());
diff --git a/src/objects/intl-objects.h b/src/objects/intl-objects.h
index 7f4b66b0fa..210ef61a0f 100644
--- a/src/objects/intl-objects.h
+++ b/src/objects/intl-objects.h
@@ -285,7 +285,7 @@ class Intl {
UErrorCode status = U_ZERO_ERROR;
UEnumeration* uenum =
uloc_openAvailableByType(ULOC_AVAILABLE_WITH_LEGACY_ALIASES, &status);
- DCHECK(U_SUCCESS(status));
+ if (!U_SUCCESS(status)) return;
std::vector<std::string> all_locales;
const char* loc;
diff --git a/src/objects/js-date-time-format.cc b/src/objects/js-date-time-format.cc
index 82d6d067e2..1b73ce8e2e 100644
--- a/src/objects/js-date-time-format.cc
+++ b/src/objects/js-date-time-format.cc
@@ -2250,8 +2250,12 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
// requestedLocales, opt, %DateTimeFormat%.[[RelevantExtensionKeys]],
// localeData).
//
+ const auto& available_locales = JSDateTimeFormat::GetAvailableLocales();
+ if (available_locales.empty()) {
+ THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError), JSDateTimeFormat);
+ }
Maybe<Intl::ResolvedLocale> maybe_resolve_locale = Intl::ResolveLocale(
- isolate, JSDateTimeFormat::GetAvailableLocales(), requested_locales,
+ isolate, available_locales, requested_locales,
locale_matcher, relevant_extension_keys);
if (maybe_resolve_locale.IsNothing()) {
THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),
diff --git a/src/objects/js-objects.cc b/src/objects/js-objects.cc
index 0a031a741c..19e610515c 100644
--- a/src/objects/js-objects.cc
+++ b/src/objects/js-objects.cc
@@ -5132,6 +5132,13 @@ void JSObject::SetImmutableProto(Handle<JSObject> object) {
object->set_map(*new_map, kReleaseStore);
}
+void JSObject::SetHostDelegate(Handle<JSObject> object) {
+ Handle<Map> map(object->map(), object->GetIsolate());
+ if (map->is_host_delegate()) return;
+ Handle<Map> new_map = Map::TransitionToHostDelegate(object->GetIsolate(), map);
+ object->set_map(*new_map, kReleaseStore);
+}
+
void JSObject::EnsureCanContainElements(Handle<JSObject> object,
JavaScriptArguments* args,
uint32_t arg_count,
diff --git a/src/objects/js-objects.h b/src/objects/js-objects.h
index 06489c2b7b..927d68d926 100644
--- a/src/objects/js-objects.h
+++ b/src/objects/js-objects.h
@@ -740,6 +740,8 @@ class JSObject : public TorqueGeneratedJSObject<JSObject, JSReceiver> {
// Never called from JavaScript
static void SetImmutableProto(Handle<JSObject> object);
+ static void SetHostDelegate(Handle<JSObject> object);
+
// Initializes the body starting at |start_offset|. It is responsibility of
// the caller to initialize object header. Fill the pre-allocated fields with
// undefined_value and the rest with filler_map.
diff --git a/src/objects/map-inl.h b/src/objects/map-inl.h
index 7105676b31..a28255acd0 100644
--- a/src/objects/map-inl.h
+++ b/src/objects/map-inl.h
@@ -114,6 +114,9 @@ BIT_FIELD_ACCESSORS(Map, bit_field3, may_have_interesting_symbols,
BIT_FIELD_ACCESSORS(Map, relaxed_bit_field3, construction_counter,
Map::Bits3::ConstructionCounterBits)
+// |host_bit_field| fields.
+BIT_FIELD_ACCESSORS(Map, host_bit_field, is_host_delegate, Map::HostBits::IsHostDelegateBit)
+
DEF_GETTER(Map, GetNamedInterceptor, InterceptorInfo) {
DCHECK(has_named_interceptor());
FunctionTemplateInfo info = GetFunctionTemplateInfo(cage_base);
diff --git a/src/objects/map.cc b/src/objects/map.cc
index d92b84bb68..496d699999 100644
--- a/src/objects/map.cc
+++ b/src/objects/map.cc
@@ -1177,6 +1177,7 @@ Handle<Map> Map::RawCopy(Isolate* isolate, Handle<Map> src_handle,
}
// Same as bit_field comment above.
raw.set_bit_field3(new_bit_field3);
+ raw.set_host_bit_field(src.host_bit_field());
raw.clear_padding();
}
Handle<HeapObject> prototype(src_handle->prototype(), isolate);
@@ -1303,6 +1304,12 @@ Handle<Map> Map::TransitionToImmutableProto(Isolate* isolate, Handle<Map> map) {
return new_map;
}
+Handle<Map> Map::TransitionToHostDelegate(Isolate* isolate, Handle<Map> map) {
+ Handle<Map> new_map = Map::Copy(isolate, map, "HostDelegate");
+ new_map->set_is_host_delegate(true);
+ return new_map;
+}
+
namespace {
void EnsureInitialMap(Isolate* isolate, Handle<Map> map) {
#ifdef DEBUG
diff --git a/src/objects/map.h b/src/objects/map.h
index 6f4d67f2fe..c7200d4745 100644
--- a/src/objects/map.h
+++ b/src/objects/map.h
@@ -319,6 +319,11 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
static_assert(kSlackTrackingCounterStart <=
Bits3::ConstructionCounterBits::kMax);
+ // Bit positions for |host_bits|.
+ struct HostBits {
+ DEFINE_TORQUE_GENERATED_MAP_HOST_BIT_FIELDS()
+ };
+
// Inobject slack tracking is the way to reclaim unused inobject space.
//
// The instance size is initially determined by adding some slack to
@@ -657,6 +662,8 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
DECL_BOOLEAN_ACCESSORS(is_immutable_proto)
+ DECL_BOOLEAN_ACCESSORS(is_host_delegate)
+
// This counter is used for in-object slack tracking.
// The in-object slack tracking is considered enabled when the counter is
// non zero. The counter only has a valid count for initial maps. For
@@ -825,6 +832,8 @@ class Map : public TorqueGeneratedMap<Map, HeapObject> {
static Handle<Map> TransitionToImmutableProto(Isolate* isolate,
Handle<Map> map);
+ static Handle<Map> TransitionToHostDelegate(Isolate* isolate, Handle<Map> map);
+
static const int kMaxPreAllocatedPropertyFields = 255;
static_assert(kInstanceTypeOffset == Internals::kMapInstanceTypeOffset);
diff --git a/src/objects/map.tq b/src/objects/map.tq
index a8b367ff82..98637087ee 100644
--- a/src/objects/map.tq
+++ b/src/objects/map.tq
@@ -34,6 +34,10 @@ bitfield struct MapBitFields3 extends uint32 {
construction_counter: int32: 3 bit;
}
+bitfield struct MapHostBitFields extends uint32 {
+ is_host_delegate: bool: 1 bit;
+}
+
extern class Map extends HeapObject {
macro PrototypeInfo(): PrototypeInfo labels HasNoPrototypeInfo {
typeswitch (this.transitions_or_prototype_info) {
@@ -65,8 +69,8 @@ extern class Map extends HeapObject {
bit_field2: MapBitFields2;
bit_field3: MapBitFields3;
- @if(TAGGED_SIZE_8_BYTES) optional_padding: uint32;
- @ifnot(TAGGED_SIZE_8_BYTES) optional_padding: void;
+ host_bit_field: MapHostBitFields;
+ optional_padding: void;
prototype: JSReceiver|Null;
constructor_or_back_pointer_or_native_context: Object;
diff --git a/src/objects/objects.cc b/src/objects/objects.cc
index 559160358c..2ed52afab3 100644
--- a/src/objects/objects.cc
+++ b/src/objects/objects.cc
@@ -889,6 +889,12 @@ Handle<String> Object::TypeOf(Isolate* isolate, Handle<Object> object) {
if (object->IsString()) return isolate->factory()->string_string();
if (object->IsSymbol()) return isolate->factory()->symbol_string();
if (object->IsBigInt()) return isolate->factory()->bigint_string();
+ if (object->IsJSObject()) {
+ Handle<JSObject> obj = Handle<JSObject>::cast(object);
+ if (obj->HasNamedInterceptor()) {
+ return obj->map().is_host_delegate() ? isolate->factory()->function_string() : isolate->factory()->object_string();
+ }
+ }
if (object->IsCallable()) return isolate->factory()->function_string();
return isolate->factory()->object_string();
}
diff --git a/src/objects/source-text-module.cc b/src/objects/source-text-module.cc
index eac227b7a5..b04523843b 100644
--- a/src/objects/source-text-module.cc
+++ b/src/objects/source-text-module.cc
@@ -737,7 +737,7 @@ MaybeHandle<Object> SourceTextModule::Evaluate(
if (!module->IsAsyncEvaluating()) {
// i. Perform ! Call(capability.[[Resolve]], undefined,
// «undefined»).
- JSPromise::Resolve(capability, isolate->factory()->undefined_value())
+ JSPromise::Resolve(capability, unused_result)
.ToHandleChecked();
}
@@ -750,7 +750,7 @@ MaybeHandle<Object> SourceTextModule::Evaluate(
}
Maybe<bool> SourceTextModule::AsyncModuleExecutionFulfilled(
- Isolate* isolate, Handle<SourceTextModule> module) {
+ Isolate* isolate, Handle<SourceTextModule> module, Handle<Object> result) {
// 1. If module.[[Status]] is evaluated, then
if (module->status() == kErrored) {
// a. Assert: module.[[EvaluationError]] is not empty.
@@ -774,7 +774,7 @@ Maybe<bool> SourceTextModule::AsyncModuleExecutionFulfilled(
// «undefined»).
Handle<JSPromise> capability(
JSPromise::cast(module->top_level_capability()), isolate);
- JSPromise::Resolve(capability, isolate->factory()->undefined_value())
+ JSPromise::Resolve(capability, result)
.ToHandleChecked();
}
@@ -840,7 +840,7 @@ Maybe<bool> SourceTextModule::AsyncModuleExecutionFulfilled(
// undefined, «undefined»).
Handle<JSPromise> capability(
JSPromise::cast(m->top_level_capability()), isolate);
- JSPromise::Resolve(capability, isolate->factory()->undefined_value())
+ JSPromise::Resolve(capability, unused_result)
.ToHandleChecked();
}
}
diff --git a/src/objects/source-text-module.h b/src/objects/source-text-module.h
index e9e79152ae..6ca03eca97 100644
--- a/src/objects/source-text-module.h
+++ b/src/objects/source-text-module.h
@@ -58,7 +58,7 @@ class SourceTextModule
// with async SourceTextModules. Return Nothing if the execution is
// terminated.
static Maybe<bool> AsyncModuleExecutionFulfilled(
- Isolate* isolate, Handle<SourceTextModule> module);
+ Isolate* isolate, Handle<SourceTextModule> module, Handle<Object> result);
static void AsyncModuleExecutionRejected(Isolate* isolate,
Handle<SourceTextModule> module,
Handle<Object> exception);
diff --git a/src/objects/templates-inl.h b/src/objects/templates-inl.h
index bb0d6a8dc6..338e11f1e1 100644
--- a/src/objects/templates-inl.h
+++ b/src/objects/templates-inl.h
@@ -170,6 +170,14 @@ void ObjectTemplateInfo::set_code_like(bool is_code_like) {
return set_data(IsCodeKindBit::update(data(), is_code_like));
}
+bool ObjectTemplateInfo::host_delegate() const {
+ return IsHostDelegateBit::decode(data());
+}
+
+void ObjectTemplateInfo::set_host_delegate(bool value) {
+ return set_data(IsHostDelegateBit::update(data(), value));
+}
+
bool FunctionTemplateInfo::IsTemplateFor(JSObject object) {
return IsTemplateFor(object.map());
}
diff --git a/src/objects/templates.h b/src/objects/templates.h
index 8ab006ab97..82e8ccfa86 100644
--- a/src/objects/templates.h
+++ b/src/objects/templates.h
@@ -202,6 +202,7 @@ class ObjectTemplateInfo
DECL_INT_ACCESSORS(embedder_field_count)
DECL_BOOLEAN_ACCESSORS(immutable_proto)
DECL_BOOLEAN_ACCESSORS(code_like)
+ DECL_BOOLEAN_ACCESSORS(host_delegate)
// Dispatched behavior.
DECL_PRINTER(ObjectTemplateInfo)
diff --git a/src/objects/templates.tq b/src/objects/templates.tq
index a3bb7a9e35..2cf7869ab4 100644
--- a/src/objects/templates.tq
+++ b/src/objects/templates.tq
@@ -71,7 +71,8 @@ extern class FunctionTemplateInfo extends TemplateInfo {
bitfield struct ObjectTemplateInfoFlags extends uint31 {
is_immutable_prototype: bool: 1 bit;
is_code_kind: bool: 1 bit;
- embedder_field_count: int32: 28 bit;
+ is_host_delegate: bool: 1 bit;
+ embedder_field_count: int32: 27 bit;
}
extern class ObjectTemplateInfo extends TemplateInfo {