aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/api.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-03-07 08:54:53 +0100
committerMichaël Zasso <targos@protonmail.com>2018-03-07 16:48:52 +0100
commit88786fecff336342a56e6f2e7ff3b286be716e47 (patch)
tree92e6ba5b8ac8dae1a058988d20c9d27bfa654390 /deps/v8/src/api.cc
parent4e86f9b5ab83cbabf43839385bf383e6a7ef7d19 (diff)
downloadandroid-node-v8-88786fecff336342a56e6f2e7ff3b286be716e47.tar.gz
android-node-v8-88786fecff336342a56e6f2e7ff3b286be716e47.tar.bz2
android-node-v8-88786fecff336342a56e6f2e7ff3b286be716e47.zip
deps: update V8 to 6.5.254.31
PR-URL: https://github.com/nodejs/node/pull/18453 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'deps/v8/src/api.cc')
-rw-r--r--deps/v8/src/api.cc979
1 files changed, 386 insertions, 593 deletions
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc
index 856be6368b..147cc397f2 100644
--- a/deps/v8/src/api.cc
+++ b/deps/v8/src/api.cc
@@ -8,9 +8,6 @@
#ifdef V8_USE_ADDRESS_SANITIZER
#include <sanitizer/asan_interface.h>
#endif // V8_USE_ADDRESS_SANITIZER
-#if defined(LEAK_SANITIZER)
-#include <sanitizer/lsan_interface.h>
-#endif // defined(LEAK_SANITIZER)
#include <cmath> // For isnan.
#include <limits>
#include <vector>
@@ -84,6 +81,7 @@
#include "src/vm-state-inl.h"
#include "src/wasm/compilation-manager.h"
#include "src/wasm/streaming-decoder.h"
+#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-result.h"
#include "src/wasm/wasm-serialization.h"
@@ -110,9 +108,9 @@ namespace v8 {
* TODO(jochen): Remove calls form API methods to DO_NOT_USE macros.
*/
-#define LOG_API(isolate, class_name, function_name) \
- i::RuntimeCallTimerScope _runtime_timer( \
- isolate, &i::RuntimeCallStats::API_##class_name##_##function_name); \
+#define LOG_API(isolate, class_name, function_name) \
+ i::RuntimeCallTimerScope _runtime_timer( \
+ isolate, i::RuntimeCallCounterId::kAPI_##class_name##_##function_name); \
LOG(isolate, ApiEntryCall("v8::" #class_name "::" #function_name))
#define ENTER_V8_DO_NOT_USE(isolate) i::VMState<v8::OTHER> __state__((isolate))
@@ -326,9 +324,9 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) {
if (isolate == nullptr) {
// On a background thread -> we cannot retrieve memory information from the
// Isolate. Write easy-to-recognize values on the stack.
- memset(last_few_messages, 0x0badc0de, Heap::kTraceRingBufferSize + 1);
- memset(js_stacktrace, 0x0badc0de, Heap::kStacktraceBufferSize + 1);
- memset(&heap_stats, 0xbadc0de, sizeof(heap_stats));
+ memset(last_few_messages, 0x0BADC0DE, Heap::kTraceRingBufferSize + 1);
+ memset(js_stacktrace, 0x0BADC0DE, Heap::kStacktraceBufferSize + 1);
+ memset(&heap_stats, 0xBADC0DE, sizeof(heap_stats));
// Note that the embedder's oom handler won't be called in this case. We
// just crash.
FATAL("API fatal error handler returned after process out of memory");
@@ -404,7 +402,10 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) {
void Utils::ReportApiFailure(const char* location, const char* message) {
i::Isolate* isolate = i::Isolate::Current();
- FatalErrorCallback callback = isolate->exception_behavior();
+ FatalErrorCallback callback = nullptr;
+ if (isolate != nullptr) {
+ callback = isolate->exception_behavior();
+ }
if (callback == nullptr) {
base::OS::PrintError("\n#\n# Fatal error in %s\n# %s\n#\n\n", location,
message);
@@ -483,23 +484,34 @@ namespace {
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
virtual void* Allocate(size_t length) {
- void* data = AllocateUninitialized(length);
- return data == nullptr ? data : memset(data, 0, length);
+#if V8_OS_AIX && _LINUX_SOURCE_COMPAT
+ // Work around for GCC bug on AIX
+ // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79839
+ void* data = __linux_calloc(length, 1);
+#else
+ void* data = calloc(length, 1);
+#endif
+ return data;
}
- virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
+
+ virtual void* AllocateUninitialized(size_t length) {
+#if V8_OS_AIX && _LINUX_SOURCE_COMPAT
+ // Work around for GCC bug on AIX
+ // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79839
+ void* data = __linux_malloc(length);
+#else
+ void* data = malloc(length);
+#endif
+ return data;
+ }
+
virtual void Free(void* data, size_t) { free(data); }
virtual void* Reserve(size_t length) {
- size_t page_size = base::OS::AllocatePageSize();
+ size_t page_size = i::AllocatePageSize();
size_t allocated = RoundUp(length, page_size);
- void* address =
- base::OS::Allocate(base::OS::GetRandomMmapAddr(), allocated, page_size,
- base::OS::MemoryPermission::kNoAccess);
-#if defined(LEAK_SANITIZER)
- if (address != nullptr) {
- __lsan_register_root_region(address, allocated);
- }
-#endif
+ void* address = i::AllocatePages(i::GetRandomMmapAddr(), allocated,
+ page_size, PageAllocator::kNoAccess);
return address;
}
@@ -510,7 +522,9 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
return Free(data, length);
}
case v8::ArrayBuffer::Allocator::AllocationMode::kReservation: {
- CHECK(base::OS::Free(data, length));
+ size_t page_size = i::AllocatePageSize();
+ size_t allocated = RoundUp(length, page_size);
+ CHECK(i::FreePages(data, allocated));
return;
}
}
@@ -521,11 +535,11 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
v8::ArrayBuffer::Allocator::Protection protection) {
DCHECK(protection == v8::ArrayBuffer::Allocator::Protection::kNoAccess ||
protection == v8::ArrayBuffer::Allocator::Protection::kReadWrite);
- base::OS::MemoryPermission permission =
+ PageAllocator::Permission permission =
(protection == v8::ArrayBuffer::Allocator::Protection::kReadWrite)
- ? base::OS::MemoryPermission::kReadWrite
- : base::OS::MemoryPermission::kNoAccess;
- CHECK(base::OS::SetPermissions(data, length, permission));
+ ? PageAllocator::kReadWrite
+ : PageAllocator::kNoAccess;
+ CHECK(i::SetPermissions(data, length, permission));
}
};
@@ -562,7 +576,6 @@ struct SnapshotCreatorData {
: isolate_(isolate),
default_context_(),
contexts_(isolate),
- templates_(isolate),
created_(false) {}
static SnapshotCreatorData* cast(void* data) {
@@ -574,7 +587,6 @@ struct SnapshotCreatorData {
Persistent<Context> default_context_;
SerializeInternalFieldsCallback default_embedder_fields_serializer_;
PersistentValueVector<Context> contexts_;
- PersistentValueVector<Template> templates_;
std::vector<SerializeInternalFieldsCallback> embedder_fields_serializers_;
bool created_;
};
@@ -634,23 +646,81 @@ size_t SnapshotCreator::AddContext(Local<Context> context,
DCHECK(!data->created_);
Isolate* isolate = data->isolate_;
CHECK_EQ(isolate, context->GetIsolate());
- size_t index = static_cast<int>(data->contexts_.Size());
+ size_t index = data->contexts_.Size();
data->contexts_.Append(context);
data->embedder_fields_serializers_.push_back(callback);
return index;
}
size_t SnapshotCreator::AddTemplate(Local<Template> template_obj) {
- DCHECK(!template_obj.IsEmpty());
+ return AddData(template_obj);
+}
+
+size_t SnapshotCreator::AddData(i::Object* object) {
+ DCHECK_NOT_NULL(object);
SnapshotCreatorData* data = SnapshotCreatorData::cast(data_);
DCHECK(!data->created_);
- DCHECK_EQ(reinterpret_cast<i::Isolate*>(data->isolate_),
- Utils::OpenHandle(*template_obj)->GetIsolate());
- size_t index = static_cast<int>(data->templates_.Size());
- data->templates_.Append(template_obj);
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(data->isolate_);
+ i::HandleScope scope(isolate);
+ i::Handle<i::Object> obj(object, isolate);
+ i::Handle<i::ArrayList> list;
+ if (!isolate->heap()->serialized_objects()->IsArrayList()) {
+ list = i::ArrayList::New(isolate, 1);
+ } else {
+ list = i::Handle<i::ArrayList>(
+ i::ArrayList::cast(isolate->heap()->serialized_objects()));
+ }
+ size_t index = static_cast<size_t>(list->Length());
+ list = i::ArrayList::Add(list, obj);
+ isolate->heap()->SetSerializedObjects(*list);
return index;
}
+size_t SnapshotCreator::AddData(Local<Context> context, i::Object* object) {
+ DCHECK_NOT_NULL(object);
+ DCHECK(!SnapshotCreatorData::cast(data_)->created_);
+ i::Handle<i::Context> ctx = Utils::OpenHandle(*context);
+ i::Isolate* isolate = ctx->GetIsolate();
+ i::HandleScope scope(isolate);
+ i::Handle<i::Object> obj(object, isolate);
+ i::Handle<i::ArrayList> list;
+ if (!ctx->serialized_objects()->IsArrayList()) {
+ list = i::ArrayList::New(isolate, 1);
+ } else {
+ list =
+ i::Handle<i::ArrayList>(i::ArrayList::cast(ctx->serialized_objects()));
+ }
+ size_t index = static_cast<size_t>(list->Length());
+ list = i::ArrayList::Add(list, obj);
+ ctx->set_serialized_objects(*list);
+ return index;
+}
+
+namespace {
+void ConvertSerializedObjectsToFixedArray(Local<Context> context) {
+ i::Handle<i::Context> ctx = Utils::OpenHandle(*context);
+ i::Isolate* isolate = ctx->GetIsolate();
+ if (!ctx->serialized_objects()->IsArrayList()) {
+ ctx->set_serialized_objects(isolate->heap()->empty_fixed_array());
+ } else {
+ i::Handle<i::ArrayList> list(i::ArrayList::cast(ctx->serialized_objects()));
+ i::Handle<i::FixedArray> elements = i::ArrayList::Elements(list);
+ ctx->set_serialized_objects(*elements);
+ }
+}
+
+void ConvertSerializedObjectsToFixedArray(i::Isolate* isolate) {
+ if (!isolate->heap()->serialized_objects()->IsArrayList()) {
+ isolate->heap()->SetSerializedObjects(isolate->heap()->empty_fixed_array());
+ } else {
+ i::Handle<i::ArrayList> list(
+ i::ArrayList::cast(isolate->heap()->serialized_objects()));
+ i::Handle<i::FixedArray> elements = i::ArrayList::Elements(list);
+ isolate->heap()->SetSerializedObjects(*elements);
+ }
+}
+} // anonymous namespace
+
StartupData SnapshotCreator::CreateBlob(
SnapshotCreator::FunctionCodeHandling function_code_handling) {
SnapshotCreatorData* data = SnapshotCreatorData::cast(data_);
@@ -661,15 +731,16 @@ StartupData SnapshotCreator::CreateBlob(
int num_additional_contexts = static_cast<int>(data->contexts_.Size());
{
- int num_templates = static_cast<int>(data->templates_.Size());
i::HandleScope scope(isolate);
- i::Handle<i::FixedArray> templates =
- isolate->factory()->NewFixedArray(num_templates, i::TENURED);
- for (int i = 0; i < num_templates; i++) {
- templates->set(i, *v8::Utils::OpenHandle(*data->templates_.Get(i)));
+ // Convert list of context-independent data to FixedArray.
+ ConvertSerializedObjectsToFixedArray(isolate);
+
+ // Convert lists of context-dependent data to FixedArray.
+ ConvertSerializedObjectsToFixedArray(
+ data->default_context_.Get(data->isolate_));
+ for (int i = 0; i < num_additional_contexts; i++) {
+ ConvertSerializedObjectsToFixedArray(data->contexts_.Get(i));
}
- isolate->heap()->SetSerializedTemplates(*templates);
- data->templates_.Clear();
// We need to store the global proxy size upfront in case we need the
// bootstrapper to create a global proxy before we deserialize the context.
@@ -695,13 +766,13 @@ StartupData SnapshotCreator::CreateBlob(
i::DisallowHeapAllocation no_gc_from_here_on;
- std::vector<i::Object*> contexts;
- contexts.reserve(num_additional_contexts);
- i::Object* default_context;
+ int num_contexts = num_additional_contexts + 1;
+ std::vector<i::Context*> contexts;
+ contexts.reserve(num_contexts);
{
i::HandleScope scope(isolate);
- default_context =
- *v8::Utils::OpenHandle(*data->default_context_.Get(data->isolate_));
+ contexts.push_back(
+ *v8::Utils::OpenHandle(*data->default_context_.Get(data->isolate_)));
data->default_context_.Reset();
for (int i = 0; i < num_additional_contexts; i++) {
i::Handle<i::Context> context =
@@ -711,6 +782,10 @@ StartupData SnapshotCreator::CreateBlob(
data->contexts_.Clear();
}
+ // Check that values referenced by global/eternal handles are accounted for.
+ i::SerializedHandleChecker handle_checker(isolate, &contexts);
+ CHECK(handle_checker.CheckGlobalAndEternalHandles());
+
// Complete in-object slack tracking for all functions.
i::HeapIterator heap_iterator(isolate->heap());
while (i::HeapObject* current_obj = heap_iterator.next()) {
@@ -724,26 +799,18 @@ StartupData SnapshotCreator::CreateBlob(
// Serialize each context with a new partial serializer.
std::vector<i::SnapshotData*> context_snapshots;
- context_snapshots.reserve(num_additional_contexts + 1);
+ context_snapshots.reserve(num_contexts);
// TODO(6593): generalize rehashing, and remove this flag.
bool can_be_rehashed = true;
- {
- // The default context is created with a handler for embedder fields which
- // determines how they are handled if encountered during serialization.
+ for (int i = 0; i < num_contexts; i++) {
+ bool is_default_context = i == 0;
i::PartialSerializer partial_serializer(
isolate, &startup_serializer,
- data->default_embedder_fields_serializer_);
- partial_serializer.Serialize(&default_context, false);
- can_be_rehashed = can_be_rehashed && partial_serializer.can_be_rehashed();
- context_snapshots.push_back(new i::SnapshotData(&partial_serializer));
- }
-
- for (int i = 0; i < num_additional_contexts; i++) {
- i::PartialSerializer partial_serializer(
- isolate, &startup_serializer, data->embedder_fields_serializers_[i]);
- partial_serializer.Serialize(&contexts[i], true);
+ is_default_context ? data->default_embedder_fields_serializer_
+ : data->embedder_fields_serializers_[i - 1]);
+ partial_serializer.Serialize(&contexts[i], !is_default_context);
can_be_rehashed = can_be_rehashed && partial_serializer.can_be_rehashed();
context_snapshots.push_back(new i::SnapshotData(&partial_serializer));
}
@@ -767,6 +834,7 @@ StartupData SnapshotCreator::CreateBlob(
delete context_snapshot;
}
data->created_ = true;
+
return result;
}
@@ -911,7 +979,8 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
uint64_t virtual_memory_limit) {
set_max_semi_space_size_in_kb(
i::Heap::ComputeMaxSemiSpaceSize(physical_memory));
- set_max_old_space_size(i::Heap::ComputeMaxOldGenerationSize(physical_memory));
+ set_max_old_space_size(
+ static_cast<int>(i::Heap::ComputeMaxOldGenerationSize(physical_memory)));
set_max_zone_pool_size(i::AccountingAllocator::kMaxPoolSize);
if (virtual_memory_limit > 0 && i::kRequiresCodeRange) {
@@ -926,9 +995,7 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory,
void SetResourceConstraints(i::Isolate* isolate,
const ResourceConstraints& constraints) {
size_t semi_space_size = constraints.max_semi_space_size_in_kb();
- size_t old_space_size =
- static_cast<size_t>(
- static_cast<unsigned int>(constraints.max_old_space_size()));
+ int old_space_size = constraints.max_old_space_size();
size_t code_range_size = constraints.code_range_size();
size_t max_pool_size = constraints.max_zone_pool_size();
if (semi_space_size != 0 || old_space_size != 0 || code_range_size != 0) {
@@ -1409,10 +1476,10 @@ Local<FunctionTemplate> FunctionTemplate::New(
MaybeLocal<FunctionTemplate> FunctionTemplate::FromSnapshot(Isolate* isolate,
size_t index) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- i::FixedArray* templates = i_isolate->heap()->serialized_templates();
+ i::FixedArray* serialized_objects = i_isolate->heap()->serialized_objects();
int int_index = static_cast<int>(index);
- if (int_index < templates->length()) {
- i::Object* info = templates->get(int_index);
+ if (int_index < serialized_objects->length()) {
+ i::Object* info = serialized_objects->get(int_index);
if (info->IsFunctionTemplateInfo()) {
return Utils::ToLocal(i::Handle<i::FunctionTemplateInfo>(
i::FunctionTemplateInfo::cast(info)));
@@ -1593,10 +1660,6 @@ Local<ObjectTemplate> ObjectTemplate::New(
}
-Local<ObjectTemplate> ObjectTemplate::New() {
- return New(i::Isolate::Current(), Local<FunctionTemplate>());
-}
-
static Local<ObjectTemplate> ObjectTemplateNew(
i::Isolate* isolate, v8::Local<FunctionTemplate> constructor,
bool do_not_cache) {
@@ -1626,10 +1689,10 @@ Local<ObjectTemplate> ObjectTemplate::New(
MaybeLocal<ObjectTemplate> ObjectTemplate::FromSnapshot(Isolate* isolate,
size_t index) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- i::FixedArray* templates = i_isolate->heap()->serialized_templates();
+ i::FixedArray* serialized_objects = i_isolate->heap()->serialized_objects();
int int_index = static_cast<int>(index);
- if (int_index < templates->length()) {
- i::Object* info = templates->get(int_index);
+ if (int_index < serialized_objects->length()) {
+ i::Object* info = serialized_objects->get(int_index);
if (info->IsObjectTemplateInfo()) {
return Utils::ToLocal(
i::Handle<i::ObjectTemplateInfo>(i::ObjectTemplateInfo::cast(info)));
@@ -1748,11 +1811,10 @@ static i::Handle<i::InterceptorInfo> CreateInterceptorInfo(
i::Isolate* isolate, Getter getter, Setter setter, Query query,
Descriptor descriptor, Deleter remover, Enumerator enumerator,
Definer definer, Local<Value> data, PropertyHandlerFlags flags) {
- DCHECK(query == nullptr ||
- descriptor == nullptr); // Either intercept attributes or descriptor.
- DCHECK(query == nullptr ||
- definer ==
- nullptr); // Only use descriptor callback with definer callback.
+ // Either intercept attributes or descriptor.
+ DCHECK(query == nullptr || descriptor == nullptr);
+ // Only use descriptor callback with definer callback.
+ DCHECK(query == nullptr || definer == nullptr);
auto obj = i::Handle<i::InterceptorInfo>::cast(
isolate->factory()->NewStruct(i::INTERCEPTOR_INFO_TYPE, i::TENURED));
obj->set_flags(0);
@@ -1781,6 +1843,32 @@ static i::Handle<i::InterceptorInfo> CreateInterceptorInfo(
template <typename Getter, typename Setter, typename Query, typename Descriptor,
typename Deleter, typename Enumerator, typename Definer>
+static i::Handle<i::InterceptorInfo> CreateNamedInterceptorInfo(
+ i::Isolate* isolate, Getter getter, Setter setter, Query query,
+ Descriptor descriptor, Deleter remover, Enumerator enumerator,
+ Definer definer, Local<Value> data, PropertyHandlerFlags flags) {
+ auto interceptor =
+ CreateInterceptorInfo(isolate, getter, setter, query, descriptor, remover,
+ enumerator, definer, data, flags);
+ interceptor->set_is_named(true);
+ return interceptor;
+}
+
+template <typename Getter, typename Setter, typename Query, typename Descriptor,
+ typename Deleter, typename Enumerator, typename Definer>
+static i::Handle<i::InterceptorInfo> CreateIndexedInterceptorInfo(
+ i::Isolate* isolate, Getter getter, Setter setter, Query query,
+ Descriptor descriptor, Deleter remover, Enumerator enumerator,
+ Definer definer, Local<Value> data, PropertyHandlerFlags flags) {
+ auto interceptor =
+ CreateInterceptorInfo(isolate, getter, setter, query, descriptor, remover,
+ enumerator, definer, data, flags);
+ interceptor->set_is_named(false);
+ return interceptor;
+}
+
+template <typename Getter, typename Setter, typename Query, typename Descriptor,
+ typename Deleter, typename Enumerator, typename Definer>
static void ObjectTemplateSetNamedPropertyHandler(
ObjectTemplate* templ, Getter getter, Setter setter, Query query,
Descriptor descriptor, Deleter remover, Enumerator enumerator,
@@ -1790,11 +1878,13 @@ static void ObjectTemplateSetNamedPropertyHandler(
i::HandleScope scope(isolate);
auto cons = EnsureConstructor(isolate, templ);
EnsureNotInstantiated(cons, "ObjectTemplateSetNamedPropertyHandler");
- auto obj = CreateInterceptorInfo(isolate, getter, setter, query, descriptor,
- remover, enumerator, definer, data, flags);
+ auto obj =
+ CreateNamedInterceptorInfo(isolate, getter, setter, query, descriptor,
+ remover, enumerator, definer, data, flags);
cons->set_named_property_handler(*obj);
}
+// TODO(cbruni) deprecate.
void ObjectTemplate::SetNamedPropertyHandler(
NamedPropertyGetterCallback getter, NamedPropertySetterCallback setter,
NamedPropertyQueryCallback query, NamedPropertyDeleterCallback remover,
@@ -1867,12 +1957,12 @@ void ObjectTemplate::SetAccessCheckCallbackAndHandler(
i::Handle<i::AccessCheckInfo>::cast(struct_info);
SET_FIELD_WRAPPED(info, set_callback, callback);
- auto named_interceptor = CreateInterceptorInfo(
+ auto named_interceptor = CreateNamedInterceptorInfo(
isolate, named_handler.getter, named_handler.setter, named_handler.query,
named_handler.descriptor, named_handler.deleter, named_handler.enumerator,
named_handler.definer, named_handler.data, named_handler.flags);
info->set_named_interceptor(*named_interceptor);
- auto indexed_interceptor = CreateInterceptorInfo(
+ auto indexed_interceptor = CreateIndexedInterceptorInfo(
isolate, indexed_handler.getter, indexed_handler.setter,
indexed_handler.query, indexed_handler.descriptor,
indexed_handler.deleter, indexed_handler.enumerator,
@@ -1895,10 +1985,10 @@ void ObjectTemplate::SetHandler(
i::HandleScope scope(isolate);
auto cons = EnsureConstructor(isolate, this);
EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetHandler");
- auto obj = CreateInterceptorInfo(isolate, config.getter, config.setter,
- config.query, config.descriptor,
- config.deleter, config.enumerator,
- config.definer, config.data, config.flags);
+ auto obj = CreateIndexedInterceptorInfo(
+ isolate, config.getter, config.setter, config.query, config.descriptor,
+ config.deleter, config.enumerator, config.definer, config.data,
+ config.flags);
cons->set_indexed_property_handler(*obj);
}
@@ -2239,11 +2329,6 @@ Local<Value> Module::GetModuleNamespace() {
int Module::GetIdentityHash() const { return Utils::OpenHandle(this)->hash(); }
-bool Module::Instantiate(Local<Context> context,
- Module::ResolveCallback callback) {
- return InstantiateModule(context, callback).FromMaybe(false);
-}
-
Maybe<bool> Module::InstantiateModule(Local<Context> context,
Module::ResolveCallback callback) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
@@ -2361,18 +2446,6 @@ MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundScript(
return CompileUnboundInternal(v8_isolate, source, options, no_cache_reason);
}
-Local<UnboundScript> ScriptCompiler::CompileUnbound(
- Isolate* v8_isolate, Source* source, CompileOptions options,
- NoCacheReason no_cache_reason) {
- Utils::ApiCheck(
- !source->GetResourceOptions().IsModule(),
- "v8::ScriptCompiler::CompileUnbound",
- "v8::ScriptCompiler::CompileModule must be used to compile modules");
- RETURN_TO_LOCAL_UNCHECKED(
- CompileUnboundInternal(v8_isolate, source, options, no_cache_reason),
- UnboundScript);
-}
-
MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
Source* source,
CompileOptions options,
@@ -2389,13 +2462,6 @@ MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
return result->BindToCurrentContext();
}
-Local<Script> ScriptCompiler::Compile(Isolate* v8_isolate, Source* source,
- CompileOptions options,
- NoCacheReason no_cache_reason) {
- auto context = v8_isolate->GetCurrentContext();
- RETURN_TO_LOCAL_UNCHECKED(Compile(context, source, options), Script);
-}
-
MaybeLocal<Module> ScriptCompiler::CompileModule(Isolate* isolate,
Source* source) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
@@ -2459,57 +2525,27 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
PREPARE_FOR_EXECUTION(v8_context, ScriptCompiler, CompileFunctionInContext,
Function);
TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.ScriptCompiler");
- i::Handle<i::String> source_string;
- auto factory = isolate->factory();
- if (arguments_count) {
- source_string = factory->NewStringFromStaticChars("(function(");
- for (size_t i = 0; i < arguments_count; ++i) {
- IsIdentifierHelper helper;
- if (!helper.Check(*Utils::OpenHandle(*arguments[i]))) {
- return Local<Function>();
- }
- has_pending_exception =
- !factory->NewConsString(source_string,
- Utils::OpenHandle(*arguments[i]))
- .ToHandle(&source_string);
- RETURN_ON_FAILED_EXECUTION(Function);
- if (i + 1 == arguments_count) continue;
- has_pending_exception =
- !factory->NewConsString(source_string,
- factory->LookupSingleCharacterStringFromCode(
- ',')).ToHandle(&source_string);
- RETURN_ON_FAILED_EXECUTION(Function);
- }
- i::Handle<i::String> brackets;
- brackets = factory->NewStringFromStaticChars("){");
- has_pending_exception = !factory->NewConsString(source_string, brackets)
- .ToHandle(&source_string);
- RETURN_ON_FAILED_EXECUTION(Function);
- } else {
- source_string = factory->NewStringFromStaticChars("(function(){");
- }
-
- int scope_position = source_string->length();
- has_pending_exception =
- !factory->NewConsString(source_string,
- Utils::OpenHandle(*source->source_string))
- .ToHandle(&source_string);
- RETURN_ON_FAILED_EXECUTION(Function);
- // Include \n in case the source contains a line end comment.
- auto brackets = factory->NewStringFromStaticChars("\n})");
- has_pending_exception =
- !factory->NewConsString(source_string, brackets).ToHandle(&source_string);
- RETURN_ON_FAILED_EXECUTION(Function);
i::Handle<i::Context> context = Utils::OpenHandle(*v8_context);
i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(),
isolate);
+
+ i::Handle<i::JSFunction> fun;
+ i::Handle<i::FixedArray> arguments_list =
+ isolate->factory()->NewFixedArray(static_cast<int>(arguments_count));
+ for (int i = 0; i < static_cast<int>(arguments_count); i++) {
+ IsIdentifierHelper helper;
+ i::Handle<i::String> argument = Utils::OpenHandle(*arguments[i]);
+ if (!helper.Check(*argument)) return Local<Function>();
+ arguments_list->set(i, *argument);
+ }
+
for (size_t i = 0; i < context_extension_count; ++i) {
i::Handle<i::JSReceiver> extension =
Utils::OpenHandle(*context_extensions[i]);
if (!extension->IsJSObject()) return Local<Function>();
i::Handle<i::JSFunction> closure(context->closure(), isolate);
- context = factory->NewWithContext(
+ context = isolate->factory()->NewWithContext(
closure, context,
i::ScopeInfo::CreateForWithScope(
isolate, context->IsNativeContext()
@@ -2519,8 +2555,6 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
}
i::Handle<i::Object> name_obj;
- int eval_scope_position = 0;
- int eval_position = i::kNoSourcePosition;
int line_offset = 0;
int column_offset = 0;
if (!source->resource_name.IsEmpty()) {
@@ -2532,27 +2566,15 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
if (!source->resource_column_offset.IsEmpty()) {
column_offset = static_cast<int>(source->resource_column_offset->Value());
}
- i::Handle<i::JSFunction> fun;
- has_pending_exception =
- !i::Compiler::GetFunctionFromEval(
- source_string, outer_info, context, i::LanguageMode::kSloppy,
- i::ONLY_SINGLE_FUNCTION_LITERAL, i::kNoSourcePosition,
- eval_scope_position, eval_position, line_offset,
- column_offset - scope_position, name_obj, source->resource_options)
- .ToHandle(&fun);
- if (has_pending_exception) {
- isolate->ReportPendingMessages();
- }
- RETURN_ON_FAILED_EXECUTION(Function);
- i::Handle<i::Object> result;
+ i::Handle<i::JSFunction> result;
has_pending_exception =
- !i::Execution::Call(isolate, fun,
- Utils::OpenHandle(*v8_context->Global()), 0,
- nullptr).ToHandle(&result);
+ !i::Compiler::GetWrappedFunction(
+ Utils::OpenHandle(*source->source_string), arguments_list, context,
+ line_offset, column_offset, name_obj, source->resource_options)
+ .ToHandle(&result);
RETURN_ON_FAILED_EXECUTION(Function);
- RETURN_ESCAPED(
- Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(result)));
+ RETURN_ESCAPED(Utils::CallableToLocal(result));
}
@@ -2587,6 +2609,9 @@ MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
i::StreamedSource* source = v8_source->impl();
i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string));
i::Handle<i::Script> script = isolate->factory()->NewScript(str);
+ if (isolate->NeedsSourcePositionsForProfiling()) {
+ i::Script::InitLineEnds(script);
+ }
if (!origin.ResourceName().IsEmpty()) {
script->set_name(*Utils::OpenHandle(*(origin.ResourceName())));
}
@@ -2643,23 +2668,49 @@ MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context,
RETURN_ESCAPED(bound);
}
-
-Local<Script> ScriptCompiler::Compile(Isolate* v8_isolate,
- StreamedSource* v8_source,
- Local<String> full_source_string,
- const ScriptOrigin& origin) {
- auto context = v8_isolate->GetCurrentContext();
- RETURN_TO_LOCAL_UNCHECKED(
- Compile(context, v8_source, full_source_string, origin), Script);
-}
-
-
uint32_t ScriptCompiler::CachedDataVersionTag() {
return static_cast<uint32_t>(base::hash_combine(
internal::Version::Hash(), internal::FlagList::Hash(),
static_cast<uint32_t>(internal::CpuFeatures::SupportedFeatures())));
}
+ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache(
+ Local<UnboundScript> unbound_script, Local<String> source) {
+ i::Handle<i::SharedFunctionInfo> shared =
+ i::Handle<i::SharedFunctionInfo>::cast(
+ Utils::OpenHandle(*unbound_script));
+ i::Isolate* isolate = shared->GetIsolate();
+ TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
+ base::ElapsedTimer timer;
+ if (i::FLAG_profile_deserialization) {
+ timer.Start();
+ }
+ i::HistogramTimerScope histogram_timer(
+ isolate->counters()->compile_serialize());
+ i::RuntimeCallTimerScope runtimeTimer(
+ isolate, i::RuntimeCallCounterId::kCompileSerialize);
+ TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileSerialize");
+
+ DCHECK(shared->is_toplevel());
+ i::Handle<i::Script> script(i::Script::cast(shared->script()));
+ // TODO(7110): Enable serialization of Asm modules once the AsmWasmData is
+ // context independent.
+ if (script->ContainsAsmModule()) return nullptr;
+ if (isolate->debug()->is_loaded()) return nullptr;
+
+ i::ScriptData* script_data =
+ i::CodeSerializer::Serialize(isolate, shared, Utils::OpenHandle(*source));
+ CachedData* result = new CachedData(
+ script_data->data(), script_data->length(), CachedData::BufferOwned);
+ script_data->ReleaseDataOwnership();
+ delete script_data;
+
+ if (i::FLAG_profile_deserialization) {
+ i::PrintF("[Serializing took %0.3f ms]\n",
+ timer.Elapsed().InMillisecondsF());
+ }
+ return result;
+}
MaybeLocal<Script> Script::Compile(Local<Context> context, Local<String> source,
ScriptOrigin* origin) {
@@ -2691,24 +2742,6 @@ Local<Script> Script::Compile(v8::Local<String> source,
// --- E x c e p t i o n s ---
-
-v8::TryCatch::TryCatch()
- : isolate_(i::Isolate::Current()),
- next_(isolate_->try_catch_handler()),
- is_verbose_(false),
- can_continue_(true),
- capture_message_(true),
- rethrow_(false),
- has_terminated_(false) {
- ResetInternal();
- // Special handling for simulators which have a separate JS stack.
- js_stack_comparable_address_ =
- reinterpret_cast<void*>(i::SimulatorStack::RegisterCTryCatch(
- isolate_, i::GetCurrentStackPosition()));
- isolate_->RegisterTryCatchHandler(this);
-}
-
-
v8::TryCatch::TryCatch(v8::Isolate* isolate)
: isolate_(reinterpret_cast<i::Isolate*>(isolate)),
next_(isolate_->try_catch_handler()),
@@ -2963,13 +2996,6 @@ Maybe<int> Message::GetEndColumn(Local<Context> context) const {
}
-int Message::GetEndColumn() const {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- const int default_value = kNoColumnInfo;
- return GetEndColumn(context).FromMaybe(default_value);
-}
-
-
bool Message::IsSharedCrossOrigin() const {
i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
@@ -3030,65 +3056,6 @@ int StackTrace::GetFrameCount() const {
return Utils::OpenHandle(this)->length();
}
-namespace {
-i::Handle<i::JSObject> NewFrameObject(i::Isolate* isolate,
- i::Handle<i::StackFrameInfo> frame) {
- i::Handle<i::JSObject> frame_obj =
- isolate->factory()->NewJSObject(isolate->object_function());
- i::JSObject::AddProperty(
- frame_obj, handle(isolate->heap()->line_string()),
- handle(i::Smi::FromInt(frame->line_number() + 1), isolate), i::NONE);
- i::JSObject::AddProperty(
- frame_obj, handle(isolate->heap()->column_string()),
- handle(i::Smi::FromInt(frame->column_number() + 1), isolate), i::NONE);
- i::JSObject::AddProperty(frame_obj,
- isolate->factory()->InternalizeOneByteString(
- STATIC_CHAR_VECTOR("scriptId")),
- handle(i::Smi::FromInt(frame->script_id()), isolate),
- i::NONE);
- i::JSObject::AddProperty(frame_obj,
- isolate->factory()->InternalizeOneByteString(
- STATIC_CHAR_VECTOR("scriptName")),
- handle(frame->script_name(), isolate), i::NONE);
- i::JSObject::AddProperty(frame_obj,
- isolate->factory()->InternalizeOneByteString(
- STATIC_CHAR_VECTOR("scriptNameOrSourceURL")),
- handle(frame->script_name_or_source_url(), isolate),
- i::NONE);
- i::JSObject::AddProperty(frame_obj,
- isolate->factory()->InternalizeOneByteString(
- STATIC_CHAR_VECTOR("functionName")),
- handle(frame->function_name(), isolate), i::NONE);
- i::JSObject::AddProperty(frame_obj,
- isolate->factory()->InternalizeOneByteString(
- STATIC_CHAR_VECTOR("isEval")),
- isolate->factory()->ToBoolean(frame->is_eval()),
- i::NONE);
- i::JSObject::AddProperty(
- frame_obj,
- isolate->factory()->InternalizeOneByteString(
- STATIC_CHAR_VECTOR("isConstructor")),
- isolate->factory()->ToBoolean(frame->is_constructor()), i::NONE);
- return frame_obj;
-}
-} // namespace
-
-Local<Array> StackTrace::AsArray() {
- i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
- i::Handle<i::FixedArray> self = Utils::OpenHandle(this);
- int frame_count = self->length();
- i::Handle<i::FixedArray> frames =
- isolate->factory()->NewFixedArray(frame_count);
- for (int i = 0; i < frame_count; ++i) {
- auto obj = handle(self->get(i), isolate);
- auto frame = i::Handle<i::StackFrameInfo>::cast(obj);
- i::Handle<i::JSObject> frame_obj = NewFrameObject(isolate, frame);
- frames->set(i, *frame_obj);
- }
- return Utils::ToLocal(isolate->factory()->NewJSArrayWithElements(
- frames, i::PACKED_ELEMENTS, frame_count));
-}
-
Local<StackTrace> StackTrace::CurrentStackTrace(
Isolate* isolate,
@@ -3193,10 +3160,6 @@ MaybeLocal<Value> JSON::Parse(Local<Context> context,
RETURN_ESCAPED(result);
}
-Local<Value> JSON::Parse(Local<String> json_string) {
- RETURN_TO_LOCAL_UNCHECKED(Parse(Local<Context>(), json_string), Value);
-}
-
MaybeLocal<String> JSON::Stringify(Local<Context> context,
Local<Value> json_object,
Local<String> gap) {
@@ -3707,12 +3670,6 @@ MaybeLocal<String> Value::ToDetailString(Local<Context> context) const {
}
-Local<String> Value::ToDetailString(Isolate* isolate) const {
- RETURN_TO_LOCAL_UNCHECKED(ToDetailString(isolate->GetCurrentContext()),
- String);
-}
-
-
MaybeLocal<Object> Value::ToObject(Local<Context> context) const {
auto obj = Utils::OpenHandle(this);
if (obj->IsJSReceiver()) return ToApiHandle<Object>(obj);
@@ -3806,11 +3763,6 @@ MaybeLocal<Uint32> Value::ToUint32(Local<Context> context) const {
}
-Local<Uint32> Value::ToUint32(Isolate* isolate) const {
- RETURN_TO_LOCAL_UNCHECKED(ToUint32(isolate->GetCurrentContext()), Uint32);
-}
-
-
void i::Internals::CheckInitializedImpl(v8::Isolate* external_isolate) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(external_isolate);
Utils::ApiCheck(isolate != nullptr && !isolate->IsDead(),
@@ -3866,6 +3818,15 @@ void v8::Symbol::CheckCast(v8::Value* that) {
}
+void v8::Private::CheckCast(v8::Data* that) {
+ i::Handle<i::Object> obj = Utils::OpenHandle(that);
+ Utils::ApiCheck(obj->IsSymbol() &&
+ i::Handle<i::Symbol>::cast(obj)->is_private(),
+ "v8::Private::Cast",
+ "Could not convert to private");
+}
+
+
void v8::Number::CheckCast(v8::Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
Utils::ApiCheck(obj->IsNumber(),
@@ -4180,17 +4141,6 @@ MaybeLocal<Uint32> Value::ToArrayIndex(Local<Context> context) const {
}
-Local<Uint32> Value::ToArrayIndex() const {
- auto self = Utils::OpenHandle(this);
- if (self->IsSmi()) {
- if (i::Smi::ToInt(*self) >= 0) return Utils::Uint32ToLocal(self);
- return Local<Uint32>();
- }
- auto context = ContextFromHeapObject(self);
- RETURN_TO_LOCAL_UNCHECKED(ToArrayIndex(context), Uint32);
-}
-
-
Maybe<bool> Value::Equals(Local<Context> context, Local<Value> that) const {
auto self = Utils::OpenHandle(this);
auto other = Utils::OpenHandle(*that);
@@ -4469,39 +4419,6 @@ Maybe<bool> v8::Object::DefineProperty(v8::Local<v8::Context> context,
return success;
}
-MUST_USE_RESULT
-static i::MaybeHandle<i::Object> DefineObjectProperty(
- i::Handle<i::JSObject> js_object, i::Handle<i::Object> key,
- i::Handle<i::Object> value, i::PropertyAttributes attrs) {
- i::Isolate* isolate = js_object->GetIsolate();
- bool success = false;
- i::LookupIterator it = i::LookupIterator::PropertyOrElement(
- isolate, js_object, key, &success, i::LookupIterator::OWN);
- if (!success) return i::MaybeHandle<i::Object>();
-
- return i::JSObject::DefineOwnPropertyIgnoreAttributes(
- &it, value, attrs, i::JSObject::FORCE_FIELD);
-}
-
-
-Maybe<bool> v8::Object::ForceSet(v8::Local<v8::Context> context,
- v8::Local<Value> key, v8::Local<Value> value,
- v8::PropertyAttribute attribs) {
- auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
- ENTER_V8_NO_SCRIPT(isolate, context, Object, ForceSet, Nothing<bool>(),
- i::HandleScope);
- auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
- auto key_obj = Utils::OpenHandle(*key);
- auto value_obj = Utils::OpenHandle(*value);
- has_pending_exception =
- DefineObjectProperty(self, key_obj, value_obj,
- static_cast<i::PropertyAttributes>(attribs))
- .is_null();
- RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
- return Just(true);
-}
-
-
Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key,
Local<Value> value) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
@@ -4595,12 +4512,6 @@ Maybe<PropertyAttribute> v8::Object::GetPropertyAttributes(
}
-PropertyAttribute v8::Object::GetPropertyAttributes(v8::Local<Value> key) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- return GetPropertyAttributes(context, key)
- .FromMaybe(static_cast<PropertyAttribute>(i::NONE));
-}
-
MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context,
Local<Name> key) {
PREPARE_FOR_EXECUTION(context, Object, GetOwnPropertyDescriptor, Value);
@@ -4618,11 +4529,6 @@ MaybeLocal<Value> v8::Object::GetOwnPropertyDescriptor(Local<Context> context,
RETURN_ESCAPED(Utils::ToLocal(desc.ToObject(isolate)));
}
-Local<Value> v8::Object::GetOwnPropertyDescriptor(Local<Name> key) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- RETURN_TO_LOCAL_UNCHECKED(GetOwnPropertyDescriptor(context, key), Value);
-}
-
Local<Value> v8::Object::GetPrototype() {
auto isolate = Utils::OpenHandle(this)->GetIsolate();
@@ -4650,11 +4556,6 @@ Maybe<bool> v8::Object::SetPrototype(Local<Context> context,
}
-bool v8::Object::SetPrototype(Local<Value> value) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- return SetPrototype(context, value).FromMaybe(false);
-}
-
Local<Object> v8::Object::FindInstanceInPrototypeChain(
v8::Local<FunctionTemplate> tmpl) {
auto self = Utils::OpenHandle(this);
@@ -4733,12 +4634,6 @@ MaybeLocal<String> v8::Object::ObjectProtoToString(Local<Context> context) {
}
-Local<String> v8::Object::ObjectProtoToString() {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- RETURN_TO_LOCAL_UNCHECKED(ObjectProtoToString(context), String);
-}
-
-
Local<String> v8::Object::GetConstructorName() {
auto self = Utils::OpenHandle(this);
i::Handle<i::String> name = i::JSReceiver::GetConstructorName(self);
@@ -4850,12 +4745,6 @@ Maybe<bool> v8::Object::Delete(Local<Context> context, uint32_t index) {
}
-bool v8::Object::Delete(uint32_t index) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- return Delete(context, index).FromMaybe(false);
-}
-
-
Maybe<bool> v8::Object::Has(Local<Context> context, uint32_t index) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
ENTER_V8(isolate, context, Object, Has, Nothing<bool>(), i::HandleScope);
@@ -4867,11 +4756,6 @@ Maybe<bool> v8::Object::Has(Local<Context> context, uint32_t index) {
}
-bool v8::Object::Has(uint32_t index) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- return Has(context, index).FromMaybe(false);
-}
-
template <typename Getter, typename Setter, typename Data>
static Maybe<bool> ObjectSetAccessor(Local<Context> context, Object* self,
Local<Name> name, Getter getter,
@@ -4918,27 +4802,6 @@ Maybe<bool> Object::SetAccessor(Local<Context> context, Local<Name> name,
}
-bool Object::SetAccessor(Local<String> name, AccessorGetterCallback getter,
- AccessorSetterCallback setter, v8::Local<Value> data,
- AccessControl settings, PropertyAttribute attributes) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- return ObjectSetAccessor(context, this, name, getter, setter, data, settings,
- attributes, i::FLAG_disable_old_api_accessors)
- .FromMaybe(false);
-}
-
-
-bool Object::SetAccessor(Local<Name> name, AccessorNameGetterCallback getter,
- AccessorNameSetterCallback setter,
- v8::Local<Value> data, AccessControl settings,
- PropertyAttribute attributes) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- return ObjectSetAccessor(context, this, name, getter, setter, data, settings,
- attributes, i::FLAG_disable_old_api_accessors)
- .FromMaybe(false);
-}
-
-
void Object::SetAccessorProperty(Local<Name> name, Local<Function> getter,
Local<Function> setter,
PropertyAttribute attribute,
@@ -4992,12 +4855,6 @@ Maybe<bool> v8::Object::HasOwnProperty(Local<Context> context, uint32_t index) {
return result;
}
-bool v8::Object::HasOwnProperty(Local<String> key) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- return HasOwnProperty(context, key).FromMaybe(false);
-}
-
-
Maybe<bool> v8::Object::HasRealNamedProperty(Local<Context> context,
Local<Name> key) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
@@ -5099,14 +4956,6 @@ MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
}
-Local<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
- Local<String> key) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- RETURN_TO_LOCAL_UNCHECKED(GetRealNamedPropertyInPrototypeChain(context, key),
- Value);
-}
-
-
Maybe<PropertyAttribute>
v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(
Local<Context> context, Local<Name> key) {
@@ -5133,13 +4982,6 @@ v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(
}
-Maybe<PropertyAttribute>
-v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(Local<String> key) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- return GetRealNamedPropertyAttributesInPrototypeChain(context, key);
-}
-
-
MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context,
Local<Name> key) {
PREPARE_FOR_EXECUTION(context, Object, GetRealNamedProperty, Value);
@@ -5156,12 +4998,6 @@ MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context,
}
-Local<Value> v8::Object::GetRealNamedProperty(Local<String> key) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- RETURN_TO_LOCAL_UNCHECKED(GetRealNamedProperty(context, key), Value);
-}
-
-
Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
Local<Context> context, Local<Name> key) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
@@ -5183,13 +5019,6 @@ Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
}
-Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
- Local<String> key) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- return GetRealNamedPropertyAttributes(context, key);
-}
-
-
Local<v8::Object> v8::Object::Clone() {
auto self = i::Handle<i::JSObject>::cast(Utils::OpenHandle(this));
auto isolate = self->GetIsolate();
@@ -5245,15 +5074,6 @@ MaybeLocal<Value> Object::CallAsFunction(Local<Context> context,
}
-Local<v8::Value> Object::CallAsFunction(v8::Local<v8::Value> recv, int argc,
- v8::Local<v8::Value> argv[]) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv);
- RETURN_TO_LOCAL_UNCHECKED(CallAsFunction(context, recv, argc, argv_cast),
- Value);
-}
-
-
MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc,
Local<Value> argv[]) {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
@@ -5272,13 +5092,6 @@ MaybeLocal<Value> Object::CallAsConstructor(Local<Context> context, int argc,
}
-Local<v8::Value> Object::CallAsConstructor(int argc,
- v8::Local<v8::Value> argv[]) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- Local<Value>* argv_cast = reinterpret_cast<Local<Value>*>(argv);
- RETURN_TO_LOCAL_UNCHECKED(CallAsConstructor(context, argc, argv_cast), Value);
-}
-
MaybeLocal<Function> Function::New(Local<Context> context,
FunctionCallback callback, Local<Value> data,
int length, ConstructorBehavior behavior) {
@@ -5300,12 +5113,6 @@ Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback,
}
-Local<v8::Object> Function::NewInstance() const {
- return NewInstance(Isolate::GetCurrent()->GetCurrentContext(), 0, nullptr)
- .FromMaybe(Local<Object>());
-}
-
-
MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc,
v8::Local<v8::Value> argv[]) const {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
@@ -5324,13 +5131,6 @@ MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc,
}
-Local<v8::Object> Function::NewInstance(int argc,
- v8::Local<v8::Value> argv[]) const {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- RETURN_TO_LOCAL_UNCHECKED(NewInstance(context, argc, argv), Object);
-}
-
-
MaybeLocal<v8::Value> Function::Call(Local<Context> context,
v8::Local<v8::Value> recv, int argc,
v8::Local<v8::Value> argv[]) {
@@ -5340,6 +5140,8 @@ MaybeLocal<v8::Value> Function::Call(Local<Context> context,
InternalEscapableScope);
i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
auto self = Utils::OpenHandle(this);
+ Utils::ApiCheck(!self.is_null(), "v8::Function::Call",
+ "Function to be called is a null pointer");
i::Handle<i::Object> recv_obj = Utils::OpenHandle(*recv);
STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
@@ -5474,16 +5276,6 @@ int Function::GetScriptColumnNumber() const {
}
-bool Function::IsBuiltin() const {
- auto self = Utils::OpenHandle(this);
- if (!self->IsJSFunction()) {
- return false;
- }
- auto func = i::Handle<i::JSFunction>::cast(self);
- return !func->shared()->IsUserJavaScript();
-}
-
-
int Function::ScriptId() const {
auto self = Utils::OpenHandle(this);
if (!self->IsJSFunction()) {
@@ -6397,7 +6189,9 @@ HeapStatistics::HeapStatistics()
heap_size_limit_(0),
malloced_memory_(0),
peak_malloced_memory_(0),
- does_zap_garbage_(0) {}
+ does_zap_garbage_(0),
+ number_of_native_contexts_(0),
+ number_of_detached_contexts_(0) {}
HeapSpaceStatistics::HeapSpaceStatistics(): space_name_(0),
space_size_(0),
@@ -6415,10 +6209,6 @@ HeapObjectStatistics::HeapObjectStatistics()
HeapCodeStatistics::HeapCodeStatistics()
: code_and_metadata_size_(0), bytecode_and_metadata_size_(0) {}
-bool v8::V8::InitializeICU(const char* icu_data_file) {
- return i::InitializeICU(icu_data_file);
-}
-
bool v8::V8::InitializeICUDefaultLocation(const char* exec_path,
const char* icu_data_file) {
return i::InitializeICUDefaultLocation(exec_path, icu_data_file);
@@ -6724,7 +6514,31 @@ void Context::SetErrorMessageForCodeGenerationFromStrings(Local<String> error) {
context->set_error_message_for_code_gen_from_strings(*error_handle);
}
-size_t Context::EstimatedSize() { return 0; }
+namespace {
+i::Object** GetSerializedDataFromFixedArray(i::Isolate* isolate,
+ i::FixedArray* list, size_t index) {
+ if (index < static_cast<size_t>(list->length())) {
+ int int_index = static_cast<int>(index);
+ i::Object* object = list->get(int_index);
+ if (!object->IsTheHole(isolate)) {
+ list->set_the_hole(isolate, int_index);
+ // Shrink the list so that the last element is not the hole.
+ int last = list->length() - 1;
+ while (last >= 0 && list->is_the_hole(isolate, last)) last--;
+ list->Shrink(last + 1);
+ return i::Handle<i::Object>(object, isolate).location();
+ }
+ }
+ return nullptr;
+}
+} // anonymous namespace
+
+i::Object** Context::GetDataFromSnapshotOnce(size_t index) {
+ auto context = Utils::OpenHandle(this);
+ i::Isolate* i_isolate = context->GetIsolate();
+ i::FixedArray* list = i::FixedArray::cast(context->serialized_objects());
+ return GetSerializedDataFromFixedArray(i_isolate, list, index);
+}
MaybeLocal<v8::Object> ObjectTemplate::NewInstance(Local<Context> context) {
PREPARE_FOR_EXECUTION(context, ObjectTemplate, NewInstance, Object);
@@ -6742,6 +6556,29 @@ Local<v8::Object> ObjectTemplate::NewInstance() {
RETURN_TO_LOCAL_UNCHECKED(NewInstance(context), Object);
}
+void v8::ObjectTemplate::CheckCast(Data* that) {
+ i::Handle<i::Object> obj = Utils::OpenHandle(that);
+ Utils::ApiCheck(obj->IsObjectTemplateInfo(), "v8::ObjectTemplate::Cast",
+ "Could not convert to object template");
+}
+
+void v8::FunctionTemplate::CheckCast(Data* that) {
+ i::Handle<i::Object> obj = Utils::OpenHandle(that);
+ Utils::ApiCheck(obj->IsFunctionTemplateInfo(), "v8::FunctionTemplate::Cast",
+ "Could not convert to function template");
+}
+
+void v8::Signature::CheckCast(Data* that) {
+ i::Handle<i::Object> obj = Utils::OpenHandle(that);
+ Utils::ApiCheck(obj->IsFunctionTemplateInfo(), "v8::Signature::Cast",
+ "Could not convert to signature");
+}
+
+void v8::AccessorSignature::CheckCast(Data* that) {
+ i::Handle<i::Object> obj = Utils::OpenHandle(that);
+ Utils::ApiCheck(obj->IsFunctionTemplateInfo(), "v8::AccessorSignature::Cast",
+ "Could not convert to accessor signature");
+}
MaybeLocal<v8::Function> FunctionTemplate::GetFunction(Local<Context> context) {
PREPARE_FOR_EXECUTION(context, FunctionTemplate, GetFunction, Function);
@@ -6915,16 +6752,6 @@ MaybeLocal<String> String::NewFromUtf8(Isolate* isolate, const char* data,
}
-Local<String> String::NewFromOneByte(Isolate* isolate,
- const uint8_t* data,
- NewStringType type,
- int length) {
- NEW_STRING(isolate, String, NewFromOneByte, uint8_t, data,
- static_cast<v8::NewStringType>(type), length);
- RETURN_TO_LOCAL_UNCHECKED(result, String);
-}
-
-
MaybeLocal<String> String::NewFromOneByte(Isolate* isolate, const uint8_t* data,
v8::NewStringType type, int length) {
NEW_STRING(isolate, String, NewFromOneByte, uint8_t, data, type, length);
@@ -6991,12 +6818,6 @@ MaybeLocal<String> v8::String::NewExternalTwoByte(
}
-Local<String> v8::String::NewExternal(
- Isolate* isolate, v8::String::ExternalStringResource* resource) {
- RETURN_TO_LOCAL_UNCHECKED(NewExternalTwoByte(isolate, resource), String);
-}
-
-
MaybeLocal<String> v8::String::NewExternalOneByte(
Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) {
CHECK(resource && resource->data());
@@ -7133,11 +6954,6 @@ Local<v8::Value> v8::BooleanObject::New(Isolate* isolate, bool value) {
}
-Local<v8::Value> v8::BooleanObject::New(bool value) {
- return New(Isolate::GetCurrent(), value);
-}
-
-
bool v8::BooleanObject::ValueOf() const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
@@ -7306,27 +7122,6 @@ uint32_t v8::Array::Length() const {
}
-MaybeLocal<Object> Array::CloneElementAt(Local<Context> context,
- uint32_t index) {
- PREPARE_FOR_EXECUTION(context, Array, CloneElementAt, Object);
- auto self = Utils::OpenHandle(this);
- if (!self->HasObjectElements()) return Local<Object>();
- i::FixedArray* elms = i::FixedArray::cast(self->elements());
- i::Object* paragon = elms->get(index);
- if (!paragon->IsJSObject()) return Local<Object>();
- i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon));
- Local<Object> result;
- has_pending_exception =
- !ToLocal<Object>(isolate->factory()->CopyJSObject(paragon_handle),
- &result);
- RETURN_ON_FAILED_EXECUTION(Object);
- RETURN_ESCAPED(result);
-}
-
-
-Local<Object> Array::CloneElementAt(uint32_t index) { return Local<Object>(); }
-
-
Local<v8::Map> v8::Map::New(Isolate* isolate) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, Map, New);
@@ -7643,12 +7438,6 @@ MaybeLocal<Promise> Promise::Catch(Local<Context> context,
}
-Local<Promise> Promise::Catch(Local<Function> handler) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- RETURN_TO_LOCAL_UNCHECKED(Catch(context, handler), Promise);
-}
-
-
MaybeLocal<Promise> Promise::Then(Local<Context> context,
Local<Function> handler) {
PREPARE_FOR_EXECUTION(context, Promise, Then, Promise);
@@ -7663,12 +7452,6 @@ MaybeLocal<Promise> Promise::Then(Local<Context> context,
}
-Local<Promise> Promise::Then(Local<Function> handler) {
- auto context = ContextFromHeapObject(Utils::OpenHandle(this));
- RETURN_TO_LOCAL_UNCHECKED(Then(context, handler), Promise);
-}
-
-
bool Promise::HasHandler() {
i::Handle<i::JSReceiver> promise = Utils::OpenHandle(this);
i::Isolate* isolate = promise->GetIsolate();
@@ -7700,9 +7483,9 @@ Promise::PromiseState Promise::State() {
return static_cast<PromiseState>(js_promise->status());
}
-Local<Object> Proxy::GetTarget() {
+Local<Value> Proxy::GetTarget() {
i::Handle<i::JSProxy> self = Utils::OpenHandle(this);
- i::Handle<i::JSReceiver> target(self->target());
+ i::Handle<i::Object> target(self->target(), self->GetIsolate());
return Utils::ToLocal(target);
}
@@ -7742,8 +7525,8 @@ Local<String> WasmCompiledModule::GetWasmWireBytes() {
i::Handle<i::WasmModuleObject> obj =
i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this));
i::Handle<i::WasmCompiledModule> compiled_part =
- i::handle(i::WasmCompiledModule::cast(obj->compiled_module()));
- i::Handle<i::String> wire_bytes(compiled_part->module_bytes());
+ i::handle(obj->compiled_module());
+ i::Handle<i::String> wire_bytes(compiled_part->shared()->module_bytes());
return Local<String>::Cast(Utils::ToLocal(wire_bytes));
}
@@ -7782,20 +7565,7 @@ WasmCompiledModule::SerializedModule WasmCompiledModule::Serialize() {
i::Handle<i::WasmModuleObject>::cast(Utils::OpenHandle(this));
i::Handle<i::WasmCompiledModule> compiled_part =
i::handle(i::WasmCompiledModule::cast(obj->compiled_module()));
- if (i::FLAG_wasm_jit_to_native) {
- i::Isolate* isolate = obj->GetIsolate();
-
- return i::wasm::NativeModuleSerializer::SerializeWholeModule(isolate,
- compiled_part);
- } else {
- std::unique_ptr<i::ScriptData> script_data =
- i::WasmCompiledModuleSerializer::SerializeWasmModule(obj->GetIsolate(),
- compiled_part);
- script_data->ReleaseDataOwnership();
-
- size_t size = static_cast<size_t>(script_data->length());
- return {std::unique_ptr<const uint8_t[]>(script_data->data()), size};
- }
+ return i::wasm::SerializeNativeModule(obj->GetIsolate(), compiled_part);
}
MaybeLocal<WasmCompiledModule> WasmCompiledModule::Deserialize(
@@ -7803,25 +7573,14 @@ MaybeLocal<WasmCompiledModule> WasmCompiledModule::Deserialize(
const WasmCompiledModule::CallerOwnedBuffer& serialized_module,
const WasmCompiledModule::CallerOwnedBuffer& wire_bytes) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- i::MaybeHandle<i::FixedArray> maybe_compiled_part;
- if (i::FLAG_wasm_jit_to_native) {
- maybe_compiled_part =
- i::wasm::NativeModuleDeserializer::DeserializeFullBuffer(
- i_isolate, {serialized_module.first, serialized_module.second},
- {wire_bytes.first, wire_bytes.second});
- } else {
- int size = static_cast<int>(serialized_module.second);
- i::ScriptData sc(serialized_module.first, size);
- maybe_compiled_part =
- i::WasmCompiledModuleSerializer::DeserializeWasmModule(
- i_isolate, &sc, {wire_bytes.first, wire_bytes.second});
- }
- i::Handle<i::FixedArray> compiled_part;
- if (!maybe_compiled_part.ToHandle(&compiled_part)) {
+ i::MaybeHandle<i::WasmCompiledModule> maybe_compiled_module =
+ i::wasm::DeserializeNativeModule(
+ i_isolate, {serialized_module.first, serialized_module.second},
+ {wire_bytes.first, wire_bytes.second});
+ i::Handle<i::WasmCompiledModule> compiled_module;
+ if (!maybe_compiled_module.ToHandle(&compiled_module)) {
return MaybeLocal<WasmCompiledModule>();
}
- i::Handle<i::WasmCompiledModule> compiled_module =
- handle(i::WasmCompiledModule::cast(*compiled_part));
return Local<WasmCompiledModule>::Cast(
Utils::ToLocal(i::Handle<i::JSObject>::cast(
i::WasmModuleObject::New(i_isolate, compiled_module))));
@@ -7866,8 +7625,10 @@ WasmModuleObjectBuilderStreaming::WasmModuleObjectBuilderStreaming(
i::Handle<i::JSPromise> promise = Utils::OpenHandle(*GetPromise());
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
streaming_decoder_ =
- i_isolate->wasm_compilation_manager()->StartStreamingCompilation(
- i_isolate, handle(i_isolate->context()), promise);
+ i_isolate->wasm_engine()
+ ->compilation_manager()
+ ->StartStreamingCompilation(i_isolate, handle(i_isolate->context()),
+ promise);
}
}
@@ -7907,7 +7668,8 @@ void WasmModuleObjectBuilderStreaming::Finish() {
// will be resolved when we move to true streaming compilation.
i::wasm::AsyncCompile(reinterpret_cast<i::Isolate*>(isolate_),
Utils::OpenHandle(*promise_.Get(isolate_)),
- {wire_bytes.get(), wire_bytes.get() + total_size_});
+ {wire_bytes.get(), wire_bytes.get() + total_size_},
+ false);
}
void WasmModuleObjectBuilderStreaming::Abort(Local<Value> exception) {
@@ -7917,6 +7679,12 @@ void WasmModuleObjectBuilderStreaming::Abort(Local<Value> exception) {
if (promise->State() != v8::Promise::kPending) return;
if (i::FLAG_wasm_stream_compilation) streaming_decoder_->Abort();
+ // If there is no exception, then we do not reject the promise. The reason is
+ // that 'no exception' indicates that we are in a ScriptForbiddenScope, which
+ // means that it is not allowed to reject the promise at the moment, or
+ // execute any other JavaScript code.
+ if (exception.IsEmpty()) return;
+
Local<Promise::Resolver> resolver = promise.As<Promise::Resolver>();
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate_);
i::HandleScope scope(i_isolate);
@@ -7973,6 +7741,14 @@ v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() {
Utils::ApiCheck(!self->is_external(), "v8_ArrayBuffer_Externalize",
"ArrayBuffer already externalized");
self->set_is_external(true);
+ if (self->has_guard_region()) {
+ // Since this is being externalized, the Wasm Allocation Tracker can no
+ // longer track it.
+ //
+ // TODO(eholk): Find a way to track this across externalization
+ isolate->wasm_engine()->allocation_tracker()->ReleaseAddressSpace(
+ self->allocation_length());
+ }
isolate->heap()->UnregisterArrayBuffer(*self);
return GetContents();
@@ -8188,6 +7964,14 @@ v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::Externalize() {
Utils::ApiCheck(!self->is_external(), "v8_SharedArrayBuffer_Externalize",
"SharedArrayBuffer already externalized");
self->set_is_external(true);
+ if (self->has_guard_region()) {
+ // Since this is being externalized, the Wasm Allocation Tracker can no
+ // longer track it.
+ //
+ // TODO(eholk): Find a way to track this across externalization
+ isolate->wasm_engine()->allocation_tracker()->ReleaseAddressSpace(
+ self->allocation_length());
+ }
isolate->heap()->UnregisterArrayBuffer(*self);
return GetContents();
}
@@ -8197,14 +7981,14 @@ v8::SharedArrayBuffer::Contents v8::SharedArrayBuffer::GetContents() {
i::Handle<i::JSArrayBuffer> self = Utils::OpenHandle(this);
size_t byte_length = static_cast<size_t>(self->byte_length()->Number());
Contents contents;
+ contents.allocation_base_ = self->allocation_base();
+ contents.allocation_length_ = self->allocation_length();
+ contents.allocation_mode_ =
+ self->has_guard_region()
+ ? ArrayBufferAllocator::Allocator::AllocationMode::kReservation
+ : ArrayBufferAllocator::Allocator::AllocationMode::kNormal;
contents.data_ = self->backing_store();
contents.byte_length_ = byte_length;
- // SharedArrayBuffers never have guard regions, so their allocation and data
- // are equivalent.
- contents.allocation_base_ = self->backing_store();
- contents.allocation_length_ = byte_length;
- contents.allocation_mode_ =
- ArrayBufferAllocator::Allocator::AllocationMode::kNormal;
return contents;
}
@@ -8727,6 +8511,11 @@ Isolate::SuppressMicrotaskExecutionScope::~SuppressMicrotaskExecutionScope() {
isolate_->handle_scope_implementer()->DecrementCallDepth();
}
+i::Object** Isolate::GetDataFromSnapshotOnce(size_t index) {
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
+ i::FixedArray* list = i_isolate->heap()->serialized_objects();
+ return GetSerializedDataFromFixedArray(i_isolate, list, index);
+}
void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
@@ -8742,6 +8531,9 @@ void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) {
isolate->allocator()->GetCurrentMemoryUsage();
heap_statistics->peak_malloced_memory_ =
isolate->allocator()->GetMaxMemoryUsage();
+ heap_statistics->number_of_native_contexts_ = heap->NumberOfNativeContexts();
+ heap_statistics->number_of_detached_contexts_ =
+ heap->NumberOfDetachedContexts();
heap_statistics->does_zap_garbage_ = heap->ShouldZapGarbage();
}
@@ -8870,7 +8662,6 @@ void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) {
isolate->RemoveCallCompletedCallback(callback);
}
-
void Isolate::AddCallCompletedCallback(
DeprecatedCallCompletedCallback callback) {
AddCallCompletedCallback(reinterpret_cast<CallCompletedCallback>(callback));
@@ -8985,15 +8776,6 @@ void Isolate::SetAddHistogramSampleFunction(
}
-bool Isolate::IdleNotification(int idle_time_in_ms) {
- // Returning true tells the caller that it need not
- // continue to call IdleNotification.
- i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
- if (!i::FLAG_use_idle_notification) return true;
- return isolate->heap()->IdleNotification(idle_time_in_ms);
-}
-
-
bool Isolate::IdleNotificationDeadline(double deadline_in_seconds) {
// Returning true tells the caller that it need not
// continue to call IdleNotification.
@@ -9346,14 +9128,6 @@ Local<Message> Exception::CreateMessage(Isolate* isolate,
}
-Local<Message> Exception::CreateMessage(Local<Value> exception) {
- i::Handle<i::Object> obj = Utils::OpenHandle(*exception);
- if (!obj->IsHeapObject()) return Local<Message>();
- i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
- return CreateMessage(reinterpret_cast<Isolate*>(isolate), exception);
-}
-
-
Local<StackTrace> Exception::GetStackTrace(Local<Value> exception) {
i::Handle<i::Object> obj = Utils::OpenHandle(*exception);
if (!obj->IsJSObject()) return Local<StackTrace>();
@@ -9664,9 +9438,9 @@ bool debug::Script::GetPossibleBreakpoints(
CHECK(!start.IsEmpty());
i::Handle<i::Script> script = Utils::OpenHandle(this);
if (script->type() == i::Script::TYPE_WASM) {
- i::Handle<i::WasmCompiledModule> compiled_module(
- i::WasmCompiledModule::cast(script->wasm_compiled_module()));
- return compiled_module->GetPossibleBreakpoints(start, end, locations);
+ i::WasmSharedModuleData* shared =
+ i::WasmCompiledModule::cast(script->wasm_compiled_module())->shared();
+ return shared->GetPossibleBreakpoints(start, end, locations);
}
i::Script::InitLineEnds(script);
@@ -9715,6 +9489,7 @@ int debug::Script::GetSourceOffset(const debug::Location& location) const {
i::Handle<i::Script> script = Utils::OpenHandle(this);
if (script->type() == i::Script::TYPE_WASM) {
return i::WasmCompiledModule::cast(script->wasm_compiled_module())
+ ->shared()
->GetFunctionOffset(location.GetLineNumber()) +
location.GetColumnNumber();
}
@@ -9784,8 +9559,9 @@ int debug::WasmScript::NumFunctions() const {
DCHECK_EQ(i::Script::TYPE_WASM, script->type());
i::WasmCompiledModule* compiled_module =
i::WasmCompiledModule::cast(script->wasm_compiled_module());
- DCHECK_GE(i::kMaxInt, compiled_module->module()->functions.size());
- return static_cast<int>(compiled_module->module()->functions.size());
+ i::wasm::WasmModule* module = compiled_module->shared()->module();
+ DCHECK_GE(i::kMaxInt, module->functions.size());
+ return static_cast<int>(module->functions.size());
}
int debug::WasmScript::NumImportedFunctions() const {
@@ -9794,8 +9570,9 @@ int debug::WasmScript::NumImportedFunctions() const {
DCHECK_EQ(i::Script::TYPE_WASM, script->type());
i::WasmCompiledModule* compiled_module =
i::WasmCompiledModule::cast(script->wasm_compiled_module());
- DCHECK_GE(i::kMaxInt, compiled_module->module()->num_imported_functions);
- return static_cast<int>(compiled_module->module()->num_imported_functions);
+ i::wasm::WasmModule* module = compiled_module->shared()->module();
+ DCHECK_GE(i::kMaxInt, module->num_imported_functions);
+ return static_cast<int>(module->num_imported_functions);
}
std::pair<int, int> debug::WasmScript::GetFunctionRange(
@@ -9805,10 +9582,10 @@ std::pair<int, int> debug::WasmScript::GetFunctionRange(
DCHECK_EQ(i::Script::TYPE_WASM, script->type());
i::WasmCompiledModule* compiled_module =
i::WasmCompiledModule::cast(script->wasm_compiled_module());
+ i::wasm::WasmModule* module = compiled_module->shared()->module();
DCHECK_LE(0, function_index);
- DCHECK_GT(compiled_module->module()->functions.size(), function_index);
- i::wasm::WasmFunction& func =
- compiled_module->module()->functions[function_index];
+ DCHECK_GT(module->functions.size(), function_index);
+ i::wasm::WasmFunction& func = module->functions[function_index];
DCHECK_GE(i::kMaxInt, func.code.offset());
DCHECK_GE(i::kMaxInt, func.code.end_offset());
return std::make_pair(static_cast<int>(func.code.offset()),
@@ -9822,7 +9599,7 @@ debug::WasmDisassembly debug::WasmScript::DisassembleFunction(
DCHECK_EQ(i::Script::TYPE_WASM, script->type());
i::WasmCompiledModule* compiled_module =
i::WasmCompiledModule::cast(script->wasm_compiled_module());
- return compiled_module->DisassembleFunction(function_index);
+ return compiled_module->shared()->DisassembleFunction(function_index);
}
debug::Location::Location(int line_number, int column_number)
@@ -9851,9 +9628,6 @@ void debug::GetLoadedScripts(v8::Isolate* v8_isolate,
PersistentValueVector<debug::Script>& scripts) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
- // TODO(kozyatinskiy): remove this GC once tests are dealt with.
- isolate->heap()->CollectAllGarbage(i::Heap::kMakeHeapIterableMask,
- i::GarbageCollectionReason::kDebugger);
{
i::DisallowHeapAllocation no_gc;
i::Script::Iterator iterator(isolate);
@@ -10913,7 +10687,7 @@ void InvokeAccessorGetterCallback(
// Leaving JavaScript.
Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate,
- &RuntimeCallStats::AccessorGetterCallback);
+ RuntimeCallCounterId::kAccessorGetterCallback);
Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>(
getter));
VMState<EXTERNAL> state(isolate);
@@ -10926,7 +10700,7 @@ void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info,
v8::FunctionCallback callback) {
Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate,
- &RuntimeCallStats::InvokeFunctionCallback);
+ RuntimeCallCounterId::kInvokeFunctionCallback);
Address callback_address =
reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
VMState<EXTERNAL> state(isolate);
@@ -10934,6 +10708,25 @@ void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info,
callback(info);
}
+// Undefine macros for jumbo build.
+#undef LOG_API
+#undef ENTER_V8_DO_NOT_USE
+#undef ENTER_V8_HELPER_DO_NOT_USE
+#undef PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE
+#undef PREPARE_FOR_EXECUTION_WITH_CONTEXT
+#undef PREPARE_FOR_EXECUTION
+#undef ENTER_V8
+#undef ENTER_V8_NO_SCRIPT
+#undef ENTER_V8_NO_SCRIPT_NO_EXCEPTION
+#undef ENTER_V8_FOR_NEW_CONTEXT
+#undef EXCEPTION_BAILOUT_CHECK_SCOPED_DO_NOT_USE
+#undef RETURN_ON_FAILED_EXECUTION
+#undef RETURN_ON_FAILED_EXECUTION_PRIMITIVE
+#undef RETURN_TO_LOCAL_UNCHECKED
+#undef RETURN_ESCAPED
+#undef SET_FIELD_WRAPPED
+#undef NEW_STRING
+#undef CALLBACK_SETTER
} // namespace internal
} // namespace v8