summaryrefslogtreecommitdiff
path: root/deps/v8/src/api.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-07-25 19:30:07 +0200
committerMichaël Zasso <targos@protonmail.com>2018-07-26 08:31:50 +0200
commit6a31d05340b22fc413ee83eaacd0a5565bbbe799 (patch)
tree78f9e1c2f417244842f6422f17e1816e70317100 /deps/v8/src/api.cc
parent4d94bb2b1f72b6b612983a517a39c5545724a3ad (diff)
downloadandroid-node-v8-6a31d05340b22fc413ee83eaacd0a5565bbbe799.tar.gz
android-node-v8-6a31d05340b22fc413ee83eaacd0a5565bbbe799.tar.bz2
android-node-v8-6a31d05340b22fc413ee83eaacd0a5565bbbe799.zip
deps: update V8 to 6.8.275.24
PR-URL: https://github.com/nodejs/node/pull/21079 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yang Guo <yangguo@chromium.org>
Diffstat (limited to 'deps/v8/src/api.cc')
-rw-r--r--deps/v8/src/api.cc748
1 files changed, 256 insertions, 492 deletions
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc
index 192ad90f83..89bcb2e4fa 100644
--- a/deps/v8/src/api.cc
+++ b/deps/v8/src/api.cc
@@ -5,10 +5,7 @@
#include "src/api.h"
#include <string.h> // For memcpy, strlen.
-#ifdef V8_USE_ADDRESS_SANITIZER
-#include <sanitizer/asan_interface.h>
-#endif // V8_USE_ADDRESS_SANITIZER
-#include <cmath> // For isnan.
+#include <cmath> // For isnan.
#include <limits>
#include <vector>
#include "include/v8-profiler.h"
@@ -49,6 +46,9 @@
#include "src/json-stringifier.h"
#include "src/messages.h"
#include "src/objects-inl.h"
+#include "src/objects/api-callbacks.h"
+#include "src/objects/ordered-hash-table-inl.h"
+#include "src/objects/templates.h"
#include "src/parsing/parser.h"
#include "src/parsing/scanner-character-streams.h"
#include "src/pending-compilation-error-handler.h"
@@ -79,7 +79,6 @@
#include "src/value-serializer.h"
#include "src/version.h"
#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"
@@ -233,10 +232,20 @@ template <bool do_callback>
class CallDepthScope {
public:
explicit CallDepthScope(i::Isolate* isolate, Local<Context> context)
- : isolate_(isolate), context_(context), escaped_(false) {
+ : isolate_(isolate),
+ context_(context),
+ escaped_(false),
+ safe_for_termination_(isolate->next_v8_call_is_safe_for_termination()),
+ interrupts_scope_(isolate_, i::StackGuard::TERMINATE_EXECUTION,
+ isolate_->only_terminate_in_safe_scope()
+ ? (safe_for_termination_
+ ? i::InterruptsScope::kRunInterrupts
+ : i::InterruptsScope::kPostponeInterrupts)
+ : i::InterruptsScope::kNoop) {
// TODO(dcarney): remove this when blink stops crashing.
DCHECK(!isolate_->external_caught_exception());
isolate_->handle_scope_implementer()->IncrementCallDepth();
+ isolate_->set_next_v8_call_is_safe_for_termination(false);
if (!context.IsEmpty()) {
i::Handle<i::Context> env = Utils::OpenHandle(*context);
i::HandleScopeImplementer* impl = isolate->handle_scope_implementer();
@@ -261,6 +270,7 @@ class CallDepthScope {
#ifdef V8_CHECK_MICROTASKS_SCOPES_CONSISTENCY
if (do_callback) CheckMicrotasksScopesConsistency(isolate_);
#endif
+ isolate_->set_next_v8_call_is_safe_for_termination(safe_for_termination_);
}
void Escape() {
@@ -277,6 +287,8 @@ class CallDepthScope {
Local<Context> context_;
bool escaped_;
bool do_callback_;
+ bool safe_for_termination_;
+ i::InterruptsScope interrupts_scope_;
};
} // namespace
@@ -332,7 +344,9 @@ void i::V8::FatalProcessOutOfMemory(i::Isolate* isolate, const char* location,
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");
+ FATAL(
+ "API fatal error handler returned after process out of memory on the "
+ "background thread");
UNREACHABLE();
}
@@ -341,6 +355,10 @@ void i::V8::FatalProcessOutOfMemory(i::Isolate* isolate, const char* location,
intptr_t start_marker;
heap_stats.start_marker = &start_marker;
+ size_t ro_space_size;
+ heap_stats.ro_space_size = &ro_space_size;
+ size_t ro_space_capacity;
+ heap_stats.ro_space_capacity = &ro_space_capacity;
size_t new_space_size;
heap_stats.new_space_size = &new_space_size;
size_t new_space_capacity;
@@ -539,14 +557,15 @@ struct SnapshotCreatorData {
} // namespace
-SnapshotCreator::SnapshotCreator(const intptr_t* external_references,
+SnapshotCreator::SnapshotCreator(Isolate* isolate,
+ const intptr_t* external_references,
StartupData* existing_snapshot) {
- i::Isolate* internal_isolate = new i::Isolate(true);
- Isolate* isolate = reinterpret_cast<Isolate*>(internal_isolate);
SnapshotCreatorData* data = new SnapshotCreatorData(isolate);
data->isolate_ = isolate;
+ i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->set_array_buffer_allocator(&data->allocator_);
internal_isolate->set_api_external_references(external_references);
+ internal_isolate->enable_serializer();
isolate->Enter();
const StartupData* blob = existing_snapshot
? existing_snapshot
@@ -560,6 +579,11 @@ SnapshotCreator::SnapshotCreator(const intptr_t* external_references,
data_ = data;
}
+SnapshotCreator::SnapshotCreator(const intptr_t* external_references,
+ StartupData* existing_snapshot)
+ : SnapshotCreator(reinterpret_cast<Isolate*>(new i::Isolate()),
+ external_references, existing_snapshot) {}
+
SnapshotCreator::~SnapshotCreator() {
SnapshotCreatorData* data = SnapshotCreatorData::cast(data_);
DCHECK(data->created_);
@@ -710,6 +734,8 @@ StartupData SnapshotCreator::CreateBlob(
i::GarbageCollectionReason::kSnapshotCreator);
isolate->heap()->CompactFixedArraysOfWeakCells();
+ isolate->heap()->read_only_space()->ClearStringPaddingIfNeeded();
+
i::DisallowHeapAllocation no_gc_from_here_on;
int num_contexts = num_additional_contexts + 1;
@@ -753,7 +779,7 @@ StartupData SnapshotCreator::CreateBlob(
if (shared->CanFlushCompiled()) {
shared->FlushCompiled();
}
- DCHECK(shared->HasCodeObject() || shared->HasBuiltinId() ||
+ DCHECK(shared->HasWasmExportedFunctionData() || shared->HasBuiltinId() ||
shared->IsApiFunction());
}
}
@@ -1527,7 +1553,9 @@ i::Handle<i::AccessorInfo> MakeAccessorInfo(
}
SET_FIELD_WRAPPED(obj, set_setter, setter);
i::Address redirected = obj->redirected_getter();
- if (redirected != nullptr) SET_FIELD_WRAPPED(obj, set_js_getter, redirected);
+ if (redirected != i::kNullAddress) {
+ SET_FIELD_WRAPPED(obj, set_js_getter, redirected);
+ }
if (data.IsEmpty()) {
data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate));
}
@@ -1694,13 +1722,11 @@ static i::Handle<i::FunctionTemplateInfo> EnsureConstructor(
}
template <typename Getter, typename Setter, typename Data, typename Template>
-static void TemplateSetAccessor(Template* template_obj, v8::Local<Name> name,
- Getter getter, Setter setter, Data data,
- AccessControl settings,
- PropertyAttribute attribute,
- v8::Local<AccessorSignature> signature,
- bool is_special_data_property,
- bool replace_on_access) {
+static void TemplateSetAccessor(
+ Template* template_obj, v8::Local<Name> name, Getter getter, Setter setter,
+ Data data, AccessControl settings, PropertyAttribute attribute,
+ v8::Local<AccessorSignature> signature, bool is_special_data_property,
+ bool replace_on_access, SideEffectType getter_side_effect_type) {
auto info = Utils::OpenHandle(template_obj);
auto isolate = info->GetIsolate();
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
@@ -1710,40 +1736,38 @@ static void TemplateSetAccessor(Template* template_obj, v8::Local<Name> name,
is_special_data_property, replace_on_access);
accessor_info->set_initial_property_attributes(
static_cast<i::PropertyAttributes>(attribute));
+ accessor_info->set_has_no_side_effect(getter_side_effect_type ==
+ SideEffectType::kHasNoSideEffect);
i::ApiNatives::AddNativeDataProperty(isolate, info, accessor_info);
}
-
-void Template::SetNativeDataProperty(v8::Local<String> name,
- AccessorGetterCallback getter,
- AccessorSetterCallback setter,
- v8::Local<Value> data,
- PropertyAttribute attribute,
- v8::Local<AccessorSignature> signature,
- AccessControl settings) {
+void Template::SetNativeDataProperty(
+ v8::Local<String> name, AccessorGetterCallback getter,
+ AccessorSetterCallback setter, v8::Local<Value> data,
+ PropertyAttribute attribute, v8::Local<AccessorSignature> signature,
+ AccessControl settings, SideEffectType getter_side_effect_type) {
TemplateSetAccessor(this, name, getter, setter, data, settings, attribute,
- signature, true, false);
+ signature, true, false, getter_side_effect_type);
}
-
-void Template::SetNativeDataProperty(v8::Local<Name> name,
- AccessorNameGetterCallback getter,
- AccessorNameSetterCallback setter,
- v8::Local<Value> data,
- PropertyAttribute attribute,
- v8::Local<AccessorSignature> signature,
- AccessControl settings) {
+void Template::SetNativeDataProperty(
+ v8::Local<Name> name, AccessorNameGetterCallback getter,
+ AccessorNameSetterCallback setter, v8::Local<Value> data,
+ PropertyAttribute attribute, v8::Local<AccessorSignature> signature,
+ AccessControl settings, SideEffectType getter_side_effect_type) {
TemplateSetAccessor(this, name, getter, setter, data, settings, attribute,
- signature, true, false);
+ signature, true, false, getter_side_effect_type);
}
void Template::SetLazyDataProperty(v8::Local<Name> name,
AccessorNameGetterCallback getter,
v8::Local<Value> data,
- PropertyAttribute attribute) {
- TemplateSetAccessor(
- this, name, getter, static_cast<AccessorNameSetterCallback>(nullptr),
- data, DEFAULT, attribute, Local<AccessorSignature>(), true, true);
+ PropertyAttribute attribute,
+ SideEffectType getter_side_effect_type) {
+ TemplateSetAccessor(this, name, getter,
+ static_cast<AccessorNameSetterCallback>(nullptr), data,
+ DEFAULT, attribute, Local<AccessorSignature>(), true,
+ true, getter_side_effect_type);
}
void Template::SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic,
@@ -1757,26 +1781,28 @@ void Template::SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic,
static_cast<i::PropertyAttributes>(attribute));
}
-
void ObjectTemplate::SetAccessor(v8::Local<String> name,
AccessorGetterCallback getter,
AccessorSetterCallback setter,
v8::Local<Value> data, AccessControl settings,
PropertyAttribute attribute,
- v8::Local<AccessorSignature> signature) {
+ v8::Local<AccessorSignature> signature,
+ SideEffectType getter_side_effect_type) {
TemplateSetAccessor(this, name, getter, setter, data, settings, attribute,
- signature, i::FLAG_disable_old_api_accessors, false);
+ signature, i::FLAG_disable_old_api_accessors, false,
+ getter_side_effect_type);
}
-
void ObjectTemplate::SetAccessor(v8::Local<Name> name,
AccessorNameGetterCallback getter,
AccessorNameSetterCallback setter,
v8::Local<Value> data, AccessControl settings,
PropertyAttribute attribute,
- v8::Local<AccessorSignature> signature) {
+ v8::Local<AccessorSignature> signature,
+ SideEffectType getter_side_effect_type) {
TemplateSetAccessor(this, name, getter, setter, data, settings, attribute,
- signature, i::FLAG_disable_old_api_accessors, false);
+ signature, i::FLAG_disable_old_api_accessors, false,
+ getter_side_effect_type);
}
template <typename Getter, typename Setter, typename Query, typename Descriptor,
@@ -2298,6 +2324,15 @@ Local<Value> Module::GetModuleNamespace() {
return ToApiHandle<Value>(module_namespace);
}
+Local<UnboundModuleScript> Module::GetUnboundModuleScript() {
+ Utils::ApiCheck(
+ GetStatus() < kEvaluating, "v8::Module::GetUnboundScript",
+ "v8::Module::GetUnboundScript must be used on an unevaluated module");
+ i::Handle<i::Module> self = Utils::OpenHandle(this);
+ return ToApiHandle<UnboundModuleScript>(
+ i::Handle<i::SharedFunctionInfo>(self->GetSharedFunctionInfo()));
+}
+
int Module::GetIdentityHash() const { return Utils::OpenHandle(this)->hash(); }
Maybe<bool> Module::InstantiateModule(Local<Context> context,
@@ -2505,8 +2540,10 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
options == CompileOptions::kNoCompileOptions);
i::Handle<i::Context> context = Utils::OpenHandle(*v8_context);
- i::Handle<i::SharedFunctionInfo> outer_info(context->closure()->shared(),
- isolate);
+
+ DCHECK(context->IsNativeContext());
+ i::Handle<i::SharedFunctionInfo> outer_info(
+ context->empty_function()->shared(), isolate);
i::Handle<i::JSFunction> fun;
i::Handle<i::FixedArray> arguments_list =
@@ -2522,9 +2559,8 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext(
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 = isolate->factory()->NewWithContext(
- closure, context,
+ context,
i::ScopeInfo::CreateForWithScope(
isolate, context->IsNativeContext()
? i::Handle<i::ScopeInfo>::null()
@@ -2638,6 +2674,16 @@ ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache(
return i::CodeSerializer::Serialize(shared);
}
+// static
+ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache(
+ Local<UnboundModuleScript> unbound_module_script) {
+ i::Handle<i::SharedFunctionInfo> shared =
+ i::Handle<i::SharedFunctionInfo>::cast(
+ Utils::OpenHandle(*unbound_module_script));
+ DCHECK(shared->is_toplevel());
+ return i::CodeSerializer::Serialize(shared);
+}
+
ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCacheForFunction(
Local<Function> function, Local<String> source) {
return CreateCodeCacheForFunction(function);
@@ -5079,9 +5125,15 @@ Local<Function> Function::New(Isolate* v8_isolate, FunctionCallback callback,
.FromMaybe(Local<Function>());
}
-
MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc,
v8::Local<v8::Value> argv[]) const {
+ return NewInstanceWithSideEffectType(context, argc, argv,
+ SideEffectType::kHasSideEffect);
+}
+
+MaybeLocal<Object> Function::NewInstanceWithSideEffectType(
+ Local<Context> context, int argc, v8::Local<v8::Value> argv[],
+ SideEffectType side_effect_type) const {
auto isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
ENTER_V8(isolate, context, Function, NewInstance, MaybeLocal<Object>(),
@@ -5089,10 +5141,39 @@ MaybeLocal<Object> Function::NewInstance(Local<Context> context, int argc,
i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate);
auto self = Utils::OpenHandle(this);
STATIC_ASSERT(sizeof(v8::Local<v8::Value>) == sizeof(i::Object**));
+ bool should_set_has_no_side_effect =
+ side_effect_type == SideEffectType::kHasNoSideEffect &&
+ isolate->debug_execution_mode() == i::DebugInfo::kSideEffects;
+ if (should_set_has_no_side_effect) {
+ CHECK(self->IsJSFunction() &&
+ i::JSFunction::cast(*self)->shared()->IsApiFunction());
+ i::Object* obj =
+ i::JSFunction::cast(*self)->shared()->get_api_func_data()->call_code();
+ if (obj->IsCallHandlerInfo()) {
+ i::CallHandlerInfo* handler_info = i::CallHandlerInfo::cast(obj);
+ if (!handler_info->IsSideEffectFreeCallHandlerInfo()) {
+ handler_info->SetNextCallHasNoSideEffect();
+ }
+ }
+ }
i::Handle<i::Object>* args = reinterpret_cast<i::Handle<i::Object>*>(argv);
Local<Object> result;
has_pending_exception = !ToLocal<Object>(
i::Execution::New(isolate, self, self, argc, args), &result);
+ if (should_set_has_no_side_effect) {
+ i::Object* obj =
+ i::JSFunction::cast(*self)->shared()->get_api_func_data()->call_code();
+ if (obj->IsCallHandlerInfo()) {
+ i::CallHandlerInfo* handler_info = i::CallHandlerInfo::cast(obj);
+ if (has_pending_exception) {
+ // Restore the map if an exception prevented restoration.
+ handler_info->NextCallHasNoSideEffect();
+ } else {
+ DCHECK(handler_info->IsSideEffectCallHandlerInfo() ||
+ handler_info->IsSideEffectFreeCallHandlerInfo());
+ }
+ }
+ }
RETURN_ON_FAILED_EXECUTION(Object);
RETURN_ESCAPED(result);
}
@@ -5403,202 +5484,28 @@ bool String::ContainsOnlyOneByte() const {
}
-class Utf8LengthHelper : public i::AllStatic {
- public:
- enum State {
- kEndsWithLeadingSurrogate = 1 << 0,
- kStartsWithTrailingSurrogate = 1 << 1,
- kLeftmostEdgeIsCalculated = 1 << 2,
- kRightmostEdgeIsCalculated = 1 << 3,
- kLeftmostEdgeIsSurrogate = 1 << 4,
- kRightmostEdgeIsSurrogate = 1 << 5
- };
-
- static const uint8_t kInitialState = 0;
-
- static inline bool EndsWithSurrogate(uint8_t state) {
- return state & kEndsWithLeadingSurrogate;
- }
-
- static inline bool StartsWithSurrogate(uint8_t state) {
- return state & kStartsWithTrailingSurrogate;
- }
-
- class Visitor {
- public:
- Visitor() : utf8_length_(0), state_(kInitialState) {}
-
- void VisitOneByteString(const uint8_t* chars, int length) {
- int utf8_length = 0;
- // Add in length 1 for each non-Latin1 character.
- for (int i = 0; i < length; i++) {
- utf8_length += *chars++ >> 7;
- }
- // Add in length 1 for each character.
- utf8_length_ = utf8_length + length;
- state_ = kInitialState;
- }
-
- void VisitTwoByteString(const uint16_t* chars, int length) {
- int utf8_length = 0;
- int last_character = unibrow::Utf16::kNoPreviousCharacter;
- for (int i = 0; i < length; i++) {
- uint16_t c = chars[i];
- utf8_length += unibrow::Utf8::Length(c, last_character);
- last_character = c;
- }
- utf8_length_ = utf8_length;
- uint8_t state = 0;
- if (unibrow::Utf16::IsTrailSurrogate(chars[0])) {
- state |= kStartsWithTrailingSurrogate;
- }
- if (unibrow::Utf16::IsLeadSurrogate(chars[length-1])) {
- state |= kEndsWithLeadingSurrogate;
- }
- state_ = state;
- }
-
- static i::ConsString* VisitFlat(i::String* string,
- int* length,
- uint8_t* state) {
- Visitor visitor;
- i::ConsString* cons_string = i::String::VisitFlat(&visitor, string);
- *length = visitor.utf8_length_;
- *state = visitor.state_;
- return cons_string;
- }
-
- private:
- int utf8_length_;
- uint8_t state_;
- DISALLOW_COPY_AND_ASSIGN(Visitor);
- };
-
- static inline void MergeLeafLeft(int* length,
- uint8_t* state,
- uint8_t leaf_state) {
- bool edge_surrogate = StartsWithSurrogate(leaf_state);
- if (!(*state & kLeftmostEdgeIsCalculated)) {
- DCHECK(!(*state & kLeftmostEdgeIsSurrogate));
- *state |= kLeftmostEdgeIsCalculated
- | (edge_surrogate ? kLeftmostEdgeIsSurrogate : 0);
- } else if (EndsWithSurrogate(*state) && edge_surrogate) {
- *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates;
- }
- if (EndsWithSurrogate(leaf_state)) {
- *state |= kEndsWithLeadingSurrogate;
- } else {
- *state &= ~kEndsWithLeadingSurrogate;
- }
- }
-
- static inline void MergeLeafRight(int* length,
- uint8_t* state,
- uint8_t leaf_state) {
- bool edge_surrogate = EndsWithSurrogate(leaf_state);
- if (!(*state & kRightmostEdgeIsCalculated)) {
- DCHECK(!(*state & kRightmostEdgeIsSurrogate));
- *state |= (kRightmostEdgeIsCalculated
- | (edge_surrogate ? kRightmostEdgeIsSurrogate : 0));
- } else if (edge_surrogate && StartsWithSurrogate(*state)) {
- *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates;
- }
- if (StartsWithSurrogate(leaf_state)) {
- *state |= kStartsWithTrailingSurrogate;
- } else {
- *state &= ~kStartsWithTrailingSurrogate;
- }
- }
-
- static inline void MergeTerminal(int* length,
- uint8_t state,
- uint8_t* state_out) {
- DCHECK((state & kLeftmostEdgeIsCalculated) &&
- (state & kRightmostEdgeIsCalculated));
- if (EndsWithSurrogate(state) && StartsWithSurrogate(state)) {
- *length -= unibrow::Utf8::kBytesSavedByCombiningSurrogates;
- }
- *state_out = kInitialState |
- (state & kLeftmostEdgeIsSurrogate ? kStartsWithTrailingSurrogate : 0) |
- (state & kRightmostEdgeIsSurrogate ? kEndsWithLeadingSurrogate : 0);
- }
-
- static int Calculate(i::ConsString* current, uint8_t* state_out) {
- using internal::ConsString;
- int total_length = 0;
- uint8_t state = kInitialState;
- while (true) {
- i::String* left = current->first();
- i::String* right = current->second();
- uint8_t right_leaf_state;
- uint8_t left_leaf_state;
- int leaf_length;
- ConsString* left_as_cons =
- Visitor::VisitFlat(left, &leaf_length, &left_leaf_state);
- if (left_as_cons == nullptr) {
- total_length += leaf_length;
- MergeLeafLeft(&total_length, &state, left_leaf_state);
- }
- ConsString* right_as_cons =
- Visitor::VisitFlat(right, &leaf_length, &right_leaf_state);
- if (right_as_cons == nullptr) {
- total_length += leaf_length;
- MergeLeafRight(&total_length, &state, right_leaf_state);
- if (left_as_cons != nullptr) {
- // 1 Leaf node. Descend in place.
- current = left_as_cons;
- continue;
- } else {
- // Terminal node.
- MergeTerminal(&total_length, state, state_out);
- return total_length;
- }
- } else if (left_as_cons == nullptr) {
- // 1 Leaf node. Descend in place.
- current = right_as_cons;
- continue;
- }
- // Both strings are ConsStrings.
- // Recurse on smallest.
- if (left->length() < right->length()) {
- total_length += Calculate(left_as_cons, &left_leaf_state);
- MergeLeafLeft(&total_length, &state, left_leaf_state);
- current = right_as_cons;
- } else {
- total_length += Calculate(right_as_cons, &right_leaf_state);
- MergeLeafRight(&total_length, &state, right_leaf_state);
- current = left_as_cons;
- }
- }
- UNREACHABLE();
- }
-
- static inline int Calculate(i::ConsString* current) {
- uint8_t state = kInitialState;
- return Calculate(current, &state);
- }
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8LengthHelper);
-};
-
-
-static int Utf8Length(i::String* str, i::Isolate* isolate) {
- int length = str->length();
- if (length == 0) return 0;
- uint8_t state;
- i::ConsString* cons_string =
- Utf8LengthHelper::Visitor::VisitFlat(str, &length, &state);
- if (cons_string == nullptr) return length;
- return Utf8LengthHelper::Calculate(cons_string);
-}
-
-
int String::Utf8Length() const {
i::Handle<i::String> str = Utils::OpenHandle(this);
str = i::String::Flatten(str);
- i::Isolate* isolate = str->GetIsolate();
- return v8::Utf8Length(*str, isolate);
+ int length = str->length();
+ if (length == 0) return 0;
+ i::DisallowHeapAllocation no_gc;
+ i::String::FlatContent flat = str->GetFlatContent();
+ DCHECK(flat.IsFlat());
+ int utf8_length = 0;
+ if (flat.IsOneByte()) {
+ for (uint8_t c : flat.ToOneByteVector()) {
+ utf8_length += c >> 7;
+ }
+ utf8_length += length;
+ } else {
+ int last_character = unibrow::Utf16::kNoPreviousCharacter;
+ for (uint16_t c : flat.ToUC16Vector()) {
+ utf8_length += unibrow::Utf8::Length(c, last_character);
+ last_character = c;
+ }
+ }
+ return utf8_length;
}
@@ -5823,7 +5730,7 @@ int String::WriteUtf8(char* buffer,
if (success) return writer.CompleteWrite(write_null, nchars_ref);
} else if (capacity >= string_length) {
// First check that the buffer is large enough.
- int utf8_bytes = v8::Utf8Length(*str, isolate);
+ int utf8_bytes = Utf8Length();
if (utf8_bytes <= capacity) {
// one-byte fast path.
if (utf8_bytes == string_length) {
@@ -5843,8 +5750,6 @@ int String::WriteUtf8(char* buffer,
return WriteUtf8(buffer, -1, nchars_ref, options);
}
}
- // Recursive slow path can potentially be unreasonable slow. Flatten.
- str = i::String::Flatten(str);
Utf8WriterVisitor writer(buffer, capacity, false, replace_invalid_utf8);
i::String::VisitFlat(&writer, *str);
return writer.CompleteWrite(write_null, nchars_ref);
@@ -6083,7 +5988,7 @@ static void* ExternalValue(i::Object* obj) {
return nullptr;
}
i::Object* foreign = i::JSObject::cast(obj)->GetEmbedderField(0);
- return i::Foreign::cast(foreign)->foreign_address();
+ return reinterpret_cast<void*>(i::Foreign::cast(foreign)->foreign_address());
}
@@ -6120,7 +6025,7 @@ bool V8::TryHandleSignal(int signum, void* info, void* context) {
#endif
bool V8::RegisterDefaultSignalHandler() {
- return v8::internal::trap_handler::RegisterDefaultSignalHandler();
+ return v8::internal::trap_handler::RegisterDefaultTrapHandler();
}
bool V8::EnableWebAssemblyTrapHandler(bool use_v8_signal_handler) {
@@ -6173,7 +6078,9 @@ HeapObjectStatistics::HeapObjectStatistics()
object_size_(0) {}
HeapCodeStatistics::HeapCodeStatistics()
- : code_and_metadata_size_(0), bytecode_and_metadata_size_(0) {}
+ : code_and_metadata_size_(0),
+ bytecode_and_metadata_size_(0),
+ external_script_source_size_(0) {}
bool v8::V8::InitializeICU(const char* icu_data_file) {
return i::InitializeICU(icu_data_file);
@@ -6867,8 +6774,9 @@ bool v8::String::CanMakeExternal() {
if (obj->IsExternalString()) return false;
// Old space strings should be externalized.
- i::Isolate* isolate = obj->GetIsolate();
- return !isolate->heap()->new_space()->Contains(*obj);
+ i::Heap* heap = obj->GetIsolate()->heap();
+ return !heap->new_space()->Contains(*obj) &&
+ !heap->read_only_space()->Contains(*obj);
}
@@ -7509,9 +7417,7 @@ MaybeLocal<Proxy> Proxy::New(Local<Context> context, Local<Object> local_target,
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(obj->compiled_module());
- i::Handle<i::String> wire_bytes(compiled_part->shared()->module_bytes());
+ i::Handle<i::String> wire_bytes(obj->shared()->module_bytes());
return Local<String>::Cast(Utils::ToLocal(wire_bytes));
}
@@ -7550,7 +7456,13 @@ 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()));
- return i::wasm::SerializeNativeModule(obj->GetIsolate(), compiled_part);
+ size_t buffer_size =
+ i::wasm::GetSerializedNativeModuleSize(obj->GetIsolate(), compiled_part);
+ std::unique_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
+ if (i::wasm::SerializeNativeModule(obj->GetIsolate(), compiled_part,
+ {buffer.get(), buffer_size}))
+ return {std::move(buffer), buffer_size};
+ return {};
}
MaybeLocal<WasmCompiledModule> WasmCompiledModule::Deserialize(
@@ -7558,17 +7470,16 @@ 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::WasmCompiledModule> maybe_compiled_module =
+ i::MaybeHandle<i::WasmModuleObject> maybe_module_object =
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)) {
+ i::Handle<i::WasmModuleObject> module_object;
+ if (!maybe_module_object.ToHandle(&module_object)) {
return MaybeLocal<WasmCompiledModule>();
}
return Local<WasmCompiledModule>::Cast(
- Utils::ToLocal(i::Handle<i::JSObject>::cast(
- i::WasmModuleObject::New(i_isolate, compiled_module))));
+ Utils::ToLocal(i::Handle<i::JSObject>::cast(module_object)));
}
MaybeLocal<WasmCompiledModule> WasmCompiledModule::DeserializeOrCompile(
@@ -7607,15 +7518,10 @@ WasmModuleObjectBuilderStreaming::WasmModuleObjectBuilderStreaming(
Local<Promise::Resolver> resolver = maybe_resolver.ToLocalChecked();
promise_.Reset(isolate, resolver->GetPromise());
- if (i::FLAG_wasm_stream_compilation) {
- i::Handle<i::JSPromise> promise = Utils::OpenHandle(*GetPromise());
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
- streaming_decoder_ =
- i_isolate->wasm_engine()
- ->compilation_manager()
- ->StartStreamingCompilation(i_isolate, handle(i_isolate->context()),
- promise);
- }
+ i::Handle<i::JSPromise> promise = Utils::OpenHandle(*GetPromise());
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ streaming_decoder_ = i_isolate->wasm_engine()->StartStreamingCompilation(
+ i_isolate, handle(i_isolate->context()), promise);
}
Local<Promise> WasmModuleObjectBuilderStreaming::GetPromise() {
@@ -7624,38 +7530,11 @@ Local<Promise> WasmModuleObjectBuilderStreaming::GetPromise() {
void WasmModuleObjectBuilderStreaming::OnBytesReceived(const uint8_t* bytes,
size_t size) {
- if (i::FLAG_wasm_stream_compilation) {
- streaming_decoder_->OnBytesReceived(i::Vector<const uint8_t>(bytes, size));
- return;
- }
- std::unique_ptr<uint8_t[]> cloned_bytes(new uint8_t[size]);
- memcpy(cloned_bytes.get(), bytes, size);
- received_buffers_.push_back(
- Buffer(std::unique_ptr<const uint8_t[]>(
- const_cast<const uint8_t*>(cloned_bytes.release())),
- size));
- total_size_ += size;
+ streaming_decoder_->OnBytesReceived(i::Vector<const uint8_t>(bytes, size));
}
void WasmModuleObjectBuilderStreaming::Finish() {
- if (i::FLAG_wasm_stream_compilation) {
- streaming_decoder_->Finish();
- return;
- }
- std::unique_ptr<uint8_t[]> wire_bytes(new uint8_t[total_size_]);
- uint8_t* insert_at = wire_bytes.get();
-
- for (size_t i = 0; i < received_buffers_.size(); ++i) {
- const Buffer& buff = received_buffers_[i];
- memcpy(insert_at, buff.first.get(), buff.second);
- insert_at += buff.second;
- }
- // AsyncCompile makes its own copy of the wire bytes. This inefficiency
- // will be resolved when we move to true streaming compilation.
- auto i_isolate = reinterpret_cast<i::Isolate*>(isolate_);
- i_isolate->wasm_engine()->AsyncCompile(
- i_isolate, Utils::OpenHandle(*promise_.Get(isolate_)),
- {wire_bytes.get(), wire_bytes.get() + total_size_}, false);
+ streaming_decoder_->Finish();
}
void WasmModuleObjectBuilderStreaming::Abort(MaybeLocal<Value> exception) {
@@ -7663,7 +7542,7 @@ void WasmModuleObjectBuilderStreaming::Abort(MaybeLocal<Value> exception) {
// The promise has already been resolved, e.g. because of a compilation
// error.
if (promise->State() != v8::Promise::kPending) return;
- if (i::FLAG_wasm_stream_compilation) streaming_decoder_->Abort();
+ streaming_decoder_->Abort();
// If no exception value is provided, we do not reject the promise. This can
// happen when streaming compilation gets aborted when no script execution is
@@ -8121,49 +8000,6 @@ Local<BigInt> v8::BigInt::New(Isolate* isolate, int64_t value) {
return Utils::ToLocal(result);
}
-Local<BigInt> v8::BigInt::NewFromUnsigned(Isolate* isolate, uint64_t value) {
- CHECK(i::FLAG_harmony_bigint);
- i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
- ENTER_V8_NO_SCRIPT_NO_EXCEPTION(internal_isolate);
- i::Handle<i::BigInt> result = i::BigInt::FromUint64(internal_isolate, value);
- return Utils::ToLocal(result);
-}
-
-MaybeLocal<BigInt> v8::BigInt::NewFromWords(Local<Context> context,
- int sign_bit, int word_count,
- const uint64_t* words) {
- CHECK(i::FLAG_harmony_bigint);
- i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
- ENTER_V8_NO_SCRIPT(isolate, context, BigInt, NewFromWords,
- MaybeLocal<BigInt>(), InternalEscapableScope);
- i::MaybeHandle<i::BigInt> result =
- i::BigInt::FromWords64(isolate, sign_bit, word_count, words);
- has_pending_exception = result.is_null();
- RETURN_ON_FAILED_EXECUTION(BigInt);
- RETURN_ESCAPED(Utils::ToLocal(result.ToHandleChecked()));
-}
-
-uint64_t v8::BigInt::Uint64Value(bool* lossless) const {
- i::Handle<i::BigInt> handle = Utils::OpenHandle(this);
- return handle->AsUint64(lossless);
-}
-
-int64_t v8::BigInt::Int64Value(bool* lossless) const {
- i::Handle<i::BigInt> handle = Utils::OpenHandle(this);
- return handle->AsInt64(lossless);
-}
-
-int BigInt::WordCount() const {
- i::Handle<i::BigInt> handle = Utils::OpenHandle(this);
- return handle->Words64Count();
-}
-
-void BigInt::ToWordsArray(int* sign_bit, int* word_count,
- uint64_t* words) const {
- i::Handle<i::BigInt> handle = Utils::OpenHandle(this);
- return handle->ToWordsArray64(sign_bit, word_count, words);
-}
-
void Isolate::ReportExternalAllocationLimitReached() {
i::Heap* heap = reinterpret_cast<i::Isolate*>(this)->heap();
if (heap->gc_state() != i::Heap::NOT_IN_GC) return;
@@ -8185,7 +8021,7 @@ HeapProfiler* Isolate::GetHeapProfiler() {
CpuProfiler* Isolate::GetCpuProfiler() {
i::CpuProfiler* cpu_profiler =
- reinterpret_cast<i::Isolate*>(this)->cpu_profiler();
+ reinterpret_cast<i::Isolate*>(this)->EnsureCpuProfiler();
return reinterpret_cast<CpuProfiler*>(cpu_profiler);
}
@@ -8363,22 +8199,22 @@ Isolate* Isolate::GetCurrent() {
return reinterpret_cast<Isolate*>(isolate);
}
-
-Isolate* Isolate::New(const Isolate::CreateParams& params) {
- i::Isolate* isolate = new i::Isolate(false);
- return IsolateNewImpl(isolate, params);
+// static
+Isolate* Isolate::Allocate() {
+ return reinterpret_cast<Isolate*>(new i::Isolate());
}
+// static
// This is separate so that tests can provide a different |isolate|.
-Isolate* IsolateNewImpl(internal::Isolate* isolate,
- const v8::Isolate::CreateParams& params) {
- Isolate* v8_isolate = reinterpret_cast<Isolate*>(isolate);
+void Isolate::Initialize(Isolate* isolate,
+ const v8::Isolate::CreateParams& params) {
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
CHECK_NOT_NULL(params.array_buffer_allocator);
- isolate->set_array_buffer_allocator(params.array_buffer_allocator);
+ i_isolate->set_array_buffer_allocator(params.array_buffer_allocator);
if (params.snapshot_blob != nullptr) {
- isolate->set_snapshot_blob(params.snapshot_blob);
+ i_isolate->set_snapshot_blob(params.snapshot_blob);
} else {
- isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob());
+ i_isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob());
}
if (params.entry_hook) {
#ifdef V8_USE_SNAPSHOT
@@ -8387,7 +8223,7 @@ Isolate* IsolateNewImpl(internal::Isolate* isolate,
false, "v8::Isolate::New",
"Setting a FunctionEntryHook is only supported in no-snapshot builds.");
#endif
- isolate->set_function_entry_hook(params.entry_hook);
+ i_isolate->set_function_entry_hook(params.entry_hook);
}
auto code_event_handler = params.code_event_handler;
#ifdef ENABLE_GDB_JIT_INTERFACE
@@ -8396,44 +8232,50 @@ Isolate* IsolateNewImpl(internal::Isolate* isolate,
}
#endif // ENABLE_GDB_JIT_INTERFACE
if (code_event_handler) {
- isolate->InitializeLoggingAndCounters();
- isolate->logger()->SetCodeEventHandler(kJitCodeEventDefault,
- code_event_handler);
+ i_isolate->InitializeLoggingAndCounters();
+ i_isolate->logger()->SetCodeEventHandler(kJitCodeEventDefault,
+ code_event_handler);
}
if (params.counter_lookup_callback) {
- v8_isolate->SetCounterFunction(params.counter_lookup_callback);
+ isolate->SetCounterFunction(params.counter_lookup_callback);
}
if (params.create_histogram_callback) {
- v8_isolate->SetCreateHistogramFunction(params.create_histogram_callback);
+ isolate->SetCreateHistogramFunction(params.create_histogram_callback);
}
if (params.add_histogram_sample_callback) {
- v8_isolate->SetAddHistogramSampleFunction(
+ isolate->SetAddHistogramSampleFunction(
params.add_histogram_sample_callback);
}
- isolate->set_api_external_references(params.external_references);
- isolate->set_allow_atomics_wait(params.allow_atomics_wait);
+ i_isolate->set_api_external_references(params.external_references);
+ i_isolate->set_allow_atomics_wait(params.allow_atomics_wait);
- SetResourceConstraints(isolate, params.constraints);
+ SetResourceConstraints(i_isolate, params.constraints);
// TODO(jochen): Once we got rid of Isolate::Current(), we can remove this.
- Isolate::Scope isolate_scope(v8_isolate);
- if (params.entry_hook || !i::Snapshot::Initialize(isolate)) {
+ Isolate::Scope isolate_scope(isolate);
+ if (params.entry_hook || !i::Snapshot::Initialize(i_isolate)) {
// If snapshot data was provided and we failed to deserialize it must
// have been corrupted.
- CHECK_NULL(isolate->snapshot_blob());
+ CHECK_NULL(i_isolate->snapshot_blob());
base::ElapsedTimer timer;
if (i::FLAG_profile_deserialization) timer.Start();
- isolate->Init(nullptr);
+ i_isolate->Init(nullptr);
if (i::FLAG_profile_deserialization) {
double ms = timer.Elapsed().InMillisecondsF();
i::PrintF("[Initializing isolate from scratch took %0.3f ms]\n", ms);
}
}
- return v8_isolate;
+ i_isolate->set_only_terminate_in_safe_scope(
+ params.only_terminate_in_safe_scope);
}
+Isolate* Isolate::New(const Isolate::CreateParams& params) {
+ Isolate* isolate = Allocate();
+ Initialize(isolate, params);
+ return isolate;
+}
void Isolate::Dispose() {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
@@ -8540,6 +8382,16 @@ Isolate::SuppressMicrotaskExecutionScope::~SuppressMicrotaskExecutionScope() {
isolate_->handle_scope_implementer()->DecrementCallDepth();
}
+Isolate::SafeForTerminationScope::SafeForTerminationScope(v8::Isolate* isolate)
+ : isolate_(reinterpret_cast<i::Isolate*>(isolate)),
+ prev_value_(isolate_->next_v8_call_is_safe_for_termination()) {
+ isolate_->set_next_v8_call_is_safe_for_termination(true);
+}
+
+Isolate::SafeForTerminationScope::~SafeForTerminationScope() {
+ isolate_->set_next_v8_call_is_safe_for_termination(prev_value_);
+}
+
i::Object** Isolate::GetDataFromSnapshotOnce(size_t index) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
i::FixedArray* list = i_isolate->heap()->serialized_objects();
@@ -8635,6 +8487,8 @@ bool Isolate::GetHeapCodeAndMetadataStatistics(
code_statistics->code_and_metadata_size_ = isolate->code_and_metadata_size();
code_statistics->bytecode_and_metadata_size_ =
isolate->bytecode_and_metadata_size();
+ code_statistics->external_script_source_size_ =
+ isolate->external_script_source_size();
return true;
}
@@ -8835,7 +8689,7 @@ int Isolate::ContextDisposedNotification(bool dependant_context) {
if (!dependant_context) {
// We left the current context, we can abort all running WebAssembly
// compilations.
- isolate->wasm_engine()->compilation_manager()->AbortAllJobs();
+ isolate->wasm_engine()->AbortAllCompileJobs();
}
// TODO(ahaas): move other non-heap activity out of the heap call.
return isolate->heap()->NotifyContextDisposed(dependant_context);
@@ -8898,7 +8752,8 @@ void Isolate::SetStackLimit(uintptr_t stack_limit) {
void Isolate::GetCodeRange(void** start, size_t* length_in_bytes) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
if (isolate->heap()->memory_allocator()->code_range()->valid()) {
- *start = isolate->heap()->memory_allocator()->code_range()->start();
+ *start = reinterpret_cast<void*>(
+ isolate->heap()->memory_allocator()->code_range()->start());
*length_in_bytes =
isolate->heap()->memory_allocator()->code_range()->size();
} else {
@@ -9095,8 +8950,7 @@ String::Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local<v8::Value> obj)
TryCatch try_catch(isolate);
Local<String> str;
if (!obj->ToString(context).ToLocal(&str)) return;
- i::Handle<i::String> i_str = Utils::OpenHandle(*str);
- length_ = v8::Utf8Length(*i_str, i_isolate);
+ length_ = str->Utf8Length();
str_ = i::NewArray<char>(length_ + 1);
str->WriteUtf8(str_);
}
@@ -9413,7 +9267,7 @@ bool debug::Script::GetPossibleBreakpoints(
i::Handle<i::Script> script = Utils::OpenHandle(this);
if (script->type() == i::Script::TYPE_WASM) {
i::WasmSharedModuleData* shared =
- i::WasmCompiledModule::cast(script->wasm_compiled_module())->shared();
+ i::WasmModuleObject::cast(script->wasm_module_object())->shared();
return shared->GetPossibleBreakpoints(start, end, locations);
}
@@ -9462,7 +9316,7 @@ bool debug::Script::GetPossibleBreakpoints(
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())
+ return i::WasmModuleObject::cast(script->wasm_module_object())
->shared()
->GetFunctionOffset(location.GetLineNumber()) +
location.GetColumnNumber();
@@ -9522,6 +9376,10 @@ void debug::RemoveBreakpoint(Isolate* v8_isolate, BreakpointId id) {
isolate->debug()->RemoveBreakpoint(id);
}
+v8::Platform* debug::GetCurrentPlatform() {
+ return i::V8::GetCurrentPlatform();
+}
+
debug::WasmScript* debug::WasmScript::Cast(debug::Script* script) {
CHECK(script->IsWasm());
return static_cast<WasmScript*>(script);
@@ -9531,9 +9389,9 @@ int debug::WasmScript::NumFunctions() const {
i::DisallowHeapAllocation no_gc;
i::Handle<i::Script> script = Utils::OpenHandle(this);
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();
+ i::WasmModuleObject* module_object =
+ i::WasmModuleObject::cast(script->wasm_module_object());
+ i::wasm::WasmModule* module = module_object->shared()->module();
DCHECK_GE(i::kMaxInt, module->functions.size());
return static_cast<int>(module->functions.size());
}
@@ -9542,9 +9400,9 @@ int debug::WasmScript::NumImportedFunctions() const {
i::DisallowHeapAllocation no_gc;
i::Handle<i::Script> script = Utils::OpenHandle(this);
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();
+ i::WasmModuleObject* module_object =
+ i::WasmModuleObject::cast(script->wasm_module_object());
+ i::wasm::WasmModule* module = module_object->shared()->module();
DCHECK_GE(i::kMaxInt, module->num_imported_functions);
return static_cast<int>(module->num_imported_functions);
}
@@ -9554,9 +9412,9 @@ std::pair<int, int> debug::WasmScript::GetFunctionRange(
i::DisallowHeapAllocation no_gc;
i::Handle<i::Script> script = Utils::OpenHandle(this);
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();
+ i::WasmModuleObject* module_object =
+ i::WasmModuleObject::cast(script->wasm_module_object());
+ i::wasm::WasmModule* module = module_object->shared()->module();
DCHECK_LE(0, function_index);
DCHECK_GT(module->functions.size(), function_index);
i::wasm::WasmFunction& func = module->functions[function_index];
@@ -9570,13 +9428,13 @@ uint32_t debug::WasmScript::GetFunctionHash(int function_index) {
i::DisallowHeapAllocation no_gc;
i::Handle<i::Script> script = Utils::OpenHandle(this);
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();
+ i::WasmModuleObject* module_object =
+ i::WasmModuleObject::cast(script->wasm_module_object());
+ i::wasm::WasmModule* module = module_object->shared()->module();
DCHECK_LE(0, function_index);
DCHECK_GT(module->functions.size(), function_index);
i::wasm::WasmFunction& func = module->functions[function_index];
- i::SeqOneByteString* module_bytes = compiled_module->shared()->module_bytes();
+ i::SeqOneByteString* module_bytes = module_object->shared()->module_bytes();
i::wasm::ModuleWireBytes wire_bytes(
module_bytes->GetFlatContent().ToOneByteVector());
i::Vector<const i::byte> function_bytes = wire_bytes.GetFunctionBytes(&func);
@@ -9590,9 +9448,9 @@ debug::WasmDisassembly debug::WasmScript::DisassembleFunction(
i::DisallowHeapAllocation no_gc;
i::Handle<i::Script> script = Utils::OpenHandle(this);
DCHECK_EQ(i::Script::TYPE_WASM, script->type());
- i::WasmCompiledModule* compiled_module =
- i::WasmCompiledModule::cast(script->wasm_compiled_module());
- return compiled_module->shared()->DisassembleFunction(function_index);
+ i::WasmModuleObject* module_object =
+ i::WasmModuleObject::cast(script->wasm_module_object());
+ return module_object->shared()->DisassembleFunction(function_index);
}
debug::Location::Location(int line_number, int column_number)
@@ -9951,15 +9809,7 @@ Local<String> CpuProfileNode::GetFunctionName() const {
const i::CodeEntry* entry = node->entry();
i::Handle<i::String> name =
isolate->factory()->InternalizeUtf8String(entry->name());
- if (!entry->has_name_prefix()) {
- return ToApiHandle<String>(name);
- } else {
- // We do not expect this to fail. Change this if it does.
- i::Handle<i::String> cons = isolate->factory()->NewConsString(
- isolate->factory()->InternalizeUtf8String(entry->name_prefix()),
- name).ToHandleChecked();
- return ToApiHandle<String>(cons);
- }
+ return ToApiHandle<String>(name);
}
int debug::Coverage::BlockData::StartOffset() const { return block_->start; }
@@ -10254,74 +10104,6 @@ void CpuProfiler::SetIdle(bool is_idle) {
isolate->SetIdle(is_idle);
}
-uintptr_t CodeEvent::GetCodeStartAddress() {
- return reinterpret_cast<i::CodeEvent*>(this)->code_start_address;
-}
-
-size_t CodeEvent::GetCodeSize() {
- return reinterpret_cast<i::CodeEvent*>(this)->code_size;
-}
-
-Local<String> CodeEvent::GetFunctionName() {
- return ToApiHandle<String>(
- reinterpret_cast<i::CodeEvent*>(this)->function_name);
-}
-
-Local<String> CodeEvent::GetScriptName() {
- return ToApiHandle<String>(
- reinterpret_cast<i::CodeEvent*>(this)->script_name);
-}
-
-int CodeEvent::GetScriptLine() {
- return reinterpret_cast<i::CodeEvent*>(this)->script_line;
-}
-
-int CodeEvent::GetScriptColumn() {
- return reinterpret_cast<i::CodeEvent*>(this)->script_column;
-}
-
-CodeEventType CodeEvent::GetCodeType() {
- return reinterpret_cast<i::CodeEvent*>(this)->code_type;
-}
-
-const char* CodeEvent::GetComment() {
- return reinterpret_cast<i::CodeEvent*>(this)->comment;
-}
-
-const char* CodeEvent::GetCodeEventTypeName(CodeEventType code_event_type) {
- switch (code_event_type) {
- case kUnknownType:
- return "Unknown";
-#define V(Name) \
- case k##Name##Type: \
- return #Name;
- CODE_EVENTS_LIST(V)
-#undef V
- }
- // The execution should never pass here
- UNREACHABLE();
- // NOTE(mmarchini): Workaround to fix a compiler failure on GCC 4.9
- return "Unknown";
-}
-
-CodeEventHandler::CodeEventHandler(Isolate* isolate) {
- internal_listener_ =
- new i::ExternalCodeEventListener(reinterpret_cast<i::Isolate*>(isolate));
-}
-
-CodeEventHandler::~CodeEventHandler() {
- delete reinterpret_cast<i::ExternalCodeEventListener*>(internal_listener_);
-}
-
-void CodeEventHandler::Enable() {
- reinterpret_cast<i::ExternalCodeEventListener*>(internal_listener_)
- ->StartListening(this);
-}
-
-void CodeEventHandler::Disable() {
- reinterpret_cast<i::ExternalCodeEventListener*>(internal_listener_)
- ->StopListening();
-}
static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) {
return const_cast<i::HeapGraphEdge*>(
@@ -10558,25 +10340,9 @@ void HeapProfiler::SetGetRetainerInfosCallback(
}
void HeapProfiler::SetBuildEmbedderGraphCallback(
- LegacyBuildEmbedderGraphCallback callback) {
- reinterpret_cast<i::HeapProfiler*>(this)->AddBuildEmbedderGraphCallback(
- [](v8::Isolate* isolate, v8::EmbedderGraph* graph, void* data) {
- reinterpret_cast<LegacyBuildEmbedderGraphCallback>(data)(isolate,
- graph);
- },
- reinterpret_cast<void*>(callback));
-}
-
-void HeapProfiler::AddBuildEmbedderGraphCallback(
- BuildEmbedderGraphCallback callback, void* data) {
- reinterpret_cast<i::HeapProfiler*>(this)->AddBuildEmbedderGraphCallback(
- callback, data);
-}
-
-void HeapProfiler::RemoveBuildEmbedderGraphCallback(
- BuildEmbedderGraphCallback callback, void* data) {
- reinterpret_cast<i::HeapProfiler*>(this)->RemoveBuildEmbedderGraphCallback(
- callback, data);
+ BuildEmbedderGraphCallback callback) {
+ reinterpret_cast<i::HeapProfiler*>(this)->SetBuildEmbedderGraphCallback(
+ callback);
}
v8::Testing::StressType internal::Testing::stress_type_ =
@@ -10804,8 +10570,7 @@ void InvokeAccessorGetterCallback(
Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate,
RuntimeCallCounterId::kAccessorGetterCallback);
- Address getter_address = reinterpret_cast<Address>(reinterpret_cast<intptr_t>(
- getter));
+ Address getter_address = reinterpret_cast<Address>(getter);
VMState<EXTERNAL> state(isolate);
ExternalCallbackScope call_scope(isolate, getter_address);
getter(property, info);
@@ -10817,8 +10582,7 @@ void InvokeFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>& info,
Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
RuntimeCallTimerScope timer(isolate,
RuntimeCallCounterId::kInvokeFunctionCallback);
- Address callback_address =
- reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
+ Address callback_address = reinterpret_cast<Address>(callback);
VMState<EXTERNAL> state(isolate);
ExternalCallbackScope call_scope(isolate, callback_address);
callback(info);