diff options
Diffstat (limited to 'deps/v8/src/runtime')
-rw-r--r-- | deps/v8/src/runtime/runtime-array.cc | 5 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-classes.cc | 7 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-compiler.cc | 10 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-debug.cc | 16 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-forin.cc | 5 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-internal.cc | 6 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-literals.cc | 49 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-object.cc | 15 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-regexp.cc | 27 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-test.cc | 98 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-typedarray.cc | 15 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-wasm.cc | 14 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime.h | 5 |
13 files changed, 170 insertions, 102 deletions
diff --git a/deps/v8/src/runtime/runtime-array.cc b/deps/v8/src/runtime/runtime-array.cc index 6190b16cff..34a8b2b937 100644 --- a/deps/v8/src/runtime/runtime-array.cc +++ b/deps/v8/src/runtime/runtime-array.cc @@ -5,6 +5,7 @@ #include "src/debug/debug.h" #include "src/execution/arguments-inl.h" #include "src/execution/isolate-inl.h" +#include "src/execution/protectors-inl.h" #include "src/heap/factory.h" #include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/heap/heap-write-barrier-inl.h" @@ -136,8 +137,8 @@ RUNTIME_FUNCTION(Runtime_NewArray) { // just flip the bit on the global protector cell instead. // TODO(bmeurer): Find a better way to mark this. Global protectors // tend to back-fire over time... - if (isolate->IsArrayConstructorIntact()) { - isolate->InvalidateArrayConstructorProtector(); + if (Protectors::IsArrayConstructorIntact(isolate)) { + Protectors::InvalidateArrayConstructor(isolate); } } } diff --git a/deps/v8/src/runtime/runtime-classes.cc b/deps/v8/src/runtime/runtime-classes.cc index 522e93da3f..a4e9680a1f 100644 --- a/deps/v8/src/runtime/runtime-classes.cc +++ b/deps/v8/src/runtime/runtime-classes.cc @@ -130,7 +130,8 @@ Handle<Name> KeyToName<NumberDictionary>(Isolate* isolate, Handle<Object> key) { inline void SetHomeObject(Isolate* isolate, JSFunction method, JSObject home_object) { if (method.shared().needs_home_object()) { - const int kPropertyIndex = JSFunction::kMaybeHomeObjectDescriptorIndex; + const InternalIndex kPropertyIndex( + JSFunction::kMaybeHomeObjectDescriptorIndex); CHECK_EQ(method.map().instance_descriptors().GetKey(kPropertyIndex), ReadOnlyRoots(isolate).home_object_symbol()); @@ -303,7 +304,7 @@ bool AddDescriptorsByTemplate( // Count the number of properties that must be in the instance and // create the property array to hold the constants. int count = 0; - for (int i = 0; i < nof_descriptors; i++) { + for (InternalIndex i : InternalIndex::Range(nof_descriptors)) { PropertyDetails details = descriptors_template->GetDetails(i); if (details.location() == kDescriptor && details.kind() == kData) { count++; @@ -315,7 +316,7 @@ bool AddDescriptorsByTemplate( // Read values from |descriptors_template| and store possibly post-processed // values into "instantiated" |descriptors| array. int field_index = 0; - for (int i = 0; i < nof_descriptors; i++) { + for (InternalIndex i : InternalIndex::Range(nof_descriptors)) { Object value = descriptors_template->GetStrongValue(i); if (value.IsAccessorPair()) { Handle<AccessorPair> pair = AccessorPair::Copy( diff --git a/deps/v8/src/runtime/runtime-compiler.cc b/deps/v8/src/runtime/runtime-compiler.cc index 4364c55775..c7f3201eac 100644 --- a/deps/v8/src/runtime/runtime-compiler.cc +++ b/deps/v8/src/runtime/runtime-compiler.cc @@ -157,6 +157,9 @@ RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) { TimerEventScope<TimerEventDeoptimizeCode> timer(isolate); TRACE_EVENT0("v8", "V8.DeoptimizeCode"); Handle<JSFunction> function = deoptimizer->function(); + // For OSR the optimized code isn't installed on the function, so get the + // code object from deoptimizer. + Handle<Code> optimized_code = deoptimizer->compiled_code(); DeoptimizeKind type = deoptimizer->deopt_kind(); // TODO(turbofan): We currently need the native context to materialize @@ -174,7 +177,7 @@ RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) { // Invalidate the underlying optimized code on non-lazy deopts. if (type != DeoptimizeKind::kLazy) { - Deoptimizer::DeoptimizeFunction(*function); + Deoptimizer::DeoptimizeFunction(*function, *optimized_code); } return ReadOnlyRoots(isolate).undefined_value(); @@ -224,8 +227,7 @@ BailoutId DetermineEntryAndDisarmOSRForInterpreter(JavaScriptFrame* frame) { RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { HandleScope scope(isolate); - DCHECK_EQ(1, args.length()); - CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); + DCHECK_EQ(0, args.length()); // Only reachable when OST is enabled. CHECK(FLAG_use_osr); @@ -233,7 +235,6 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { // Determine frame triggering OSR request. JavaScriptFrameIterator it(isolate); JavaScriptFrame* frame = it.frame(); - DCHECK_EQ(frame->function(), *function); DCHECK(frame->is_interpreted()); // Determine the entry point for which this OSR request has been fired and @@ -242,6 +243,7 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { DCHECK(!ast_id.IsNone()); MaybeHandle<Code> maybe_result; + Handle<JSFunction> function(frame->function(), isolate); if (IsSuitableForOnStackReplacement(isolate, function)) { if (FLAG_trace_osr) { PrintF("[OSR - Compiling: "); diff --git a/deps/v8/src/runtime/runtime-debug.cc b/deps/v8/src/runtime/runtime-debug.cc index 0fbea6a193..09dd4f8132 100644 --- a/deps/v8/src/runtime/runtime-debug.cc +++ b/deps/v8/src/runtime/runtime-debug.cc @@ -491,8 +491,7 @@ int ScriptLinePosition(Handle<Script> script, int line) { if (line < 0) return -1; if (script->type() == Script::TYPE_WASM) { - return WasmModuleObject::cast(script->wasm_module_object()) - .GetFunctionOffset(line); + return GetWasmFunctionOffset(script->wasm_native_module()->module(), line); } Script::InitLineEnds(script); @@ -827,19 +826,6 @@ RUNTIME_FUNCTION(Runtime_LiveEditPatchScript) { return ReadOnlyRoots(isolate).undefined_value(); } -RUNTIME_FUNCTION(Runtime_PerformSideEffectCheckForObject) { - HandleScope scope(isolate); - DCHECK_EQ(1, args.length()); - CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); - - DCHECK_EQ(isolate->debug_execution_mode(), DebugInfo::kSideEffects); - if (!isolate->debug()->PerformSideEffectCheckForObject(object)) { - DCHECK(isolate->has_pending_exception()); - return ReadOnlyRoots(isolate).exception(); - } - return ReadOnlyRoots(isolate).undefined_value(); -} - RUNTIME_FUNCTION(Runtime_ProfileCreateSnapshotDataBlob) { HandleScope scope(isolate); DCHECK_EQ(0, args.length()); diff --git a/deps/v8/src/runtime/runtime-forin.cc b/deps/v8/src/runtime/runtime-forin.cc index 6042a867c9..0d7e1dc30b 100644 --- a/deps/v8/src/runtime/runtime-forin.cc +++ b/deps/v8/src/runtime/runtime-forin.cc @@ -33,7 +33,10 @@ MaybeHandle<HeapObject> Enumerate(Isolate* isolate, if (!accumulator.is_receiver_simple_enum()) { Handle<FixedArray> keys; ASSIGN_RETURN_ON_EXCEPTION( - isolate, keys, accumulator.GetKeys(GetKeysConversion::kConvertToString), + isolate, keys, + accumulator.GetKeys(accumulator.may_have_elements() + ? GetKeysConversion::kConvertToString + : GetKeysConversion::kNoNumbers), HeapObject); // Test again, since cache may have been built by GetKeys() calls above. if (!accumulator.is_receiver_simple_enum()) return keys; diff --git a/deps/v8/src/runtime/runtime-internal.cc b/deps/v8/src/runtime/runtime-internal.cc index 80f9baa48d..03c9e582d8 100644 --- a/deps/v8/src/runtime/runtime-internal.cc +++ b/deps/v8/src/runtime/runtime-internal.cc @@ -14,6 +14,7 @@ #include "src/execution/frames-inl.h" #include "src/execution/isolate-inl.h" #include "src/execution/messages.h" +#include "src/execution/runtime-profiler.h" #include "src/handles/maybe-handles.h" #include "src/init/bootstrapper.h" #include "src/logging/counters.h" @@ -296,10 +297,11 @@ RUNTIME_FUNCTION(Runtime_BytecodeBudgetInterrupt) { function->feedback_vector().set_invocation_count(1); return ReadOnlyRoots(isolate).undefined_value(); } - // Handle interrupts. { SealHandleScope shs(isolate); - return isolate->stack_guard()->HandleInterrupts(); + isolate->counters()->runtime_profiler_ticks()->Increment(); + isolate->runtime_profiler()->MarkCandidatesForOptimization(); + return ReadOnlyRoots(isolate).undefined_value(); } } diff --git a/deps/v8/src/runtime/runtime-literals.cc b/deps/v8/src/runtime/runtime-literals.cc index 0ffc6e932e..497a27dbb9 100644 --- a/deps/v8/src/runtime/runtime-literals.cc +++ b/deps/v8/src/runtime/runtime-literals.cc @@ -111,8 +111,7 @@ MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk( if (copy->HasFastProperties(isolate)) { Handle<DescriptorArray> descriptors( copy->map(isolate).instance_descriptors(isolate), isolate); - int limit = copy->map(isolate).NumberOfOwnDescriptors(); - for (int i = 0; i < limit; i++) { + for (InternalIndex i : copy->map(isolate).IterateOwnDescriptors()) { PropertyDetails details = descriptors->GetDetails(i); DCHECK_EQ(kField, details.location()); DCHECK_EQ(kData, details.kind()); @@ -595,10 +594,11 @@ RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { CONVERT_SMI_ARG_CHECKED(literals_index, 1); CONVERT_ARG_HANDLE_CHECKED(ObjectBoilerplateDescription, description, 2); CONVERT_SMI_ARG_CHECKED(flags, 3); - Handle<FeedbackVector> vector = Handle<FeedbackVector>(); - if (!maybe_vector->IsUndefined()) { - DCHECK(maybe_vector->IsFeedbackVector()); + Handle<FeedbackVector> vector; + if (maybe_vector->IsFeedbackVector()) { vector = Handle<FeedbackVector>::cast(maybe_vector); + } else { + DCHECK(maybe_vector->IsUndefined()); } RETURN_RESULT_OR_FAILURE( isolate, CreateLiteral<ObjectLiteralHelper>( @@ -632,10 +632,11 @@ RUNTIME_FUNCTION(Runtime_CreateArrayLiteral) { CONVERT_SMI_ARG_CHECKED(literals_index, 1); CONVERT_ARG_HANDLE_CHECKED(ArrayBoilerplateDescription, elements, 2); CONVERT_SMI_ARG_CHECKED(flags, 3); - Handle<FeedbackVector> vector = Handle<FeedbackVector>(); - if (!maybe_vector->IsUndefined()) { - DCHECK(maybe_vector->IsFeedbackVector()); + Handle<FeedbackVector> vector; + if (maybe_vector->IsFeedbackVector()) { vector = Handle<FeedbackVector>::cast(maybe_vector); + } else { + DCHECK(maybe_vector->IsUndefined()); } RETURN_RESULT_OR_FAILURE( isolate, CreateLiteral<ArrayLiteralHelper>( @@ -649,11 +650,12 @@ RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) { CONVERT_SMI_ARG_CHECKED(index, 1); CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); CONVERT_SMI_ARG_CHECKED(flags, 3); - FeedbackSlot literal_slot(FeedbackVector::ToSlot(index)); - Handle<FeedbackVector> vector = Handle<FeedbackVector>(); - if (!maybe_vector->IsUndefined()) { - DCHECK(maybe_vector->IsFeedbackVector()); + + Handle<FeedbackVector> vector; + if (maybe_vector->IsFeedbackVector()) { vector = Handle<FeedbackVector>::cast(maybe_vector); + } else { + DCHECK(maybe_vector->IsUndefined()); } if (vector.is_null()) { Handle<JSRegExp> new_regexp; @@ -663,20 +665,21 @@ RUNTIME_FUNCTION(Runtime_CreateRegExpLiteral) { return *new_regexp; } - // Check if boilerplate exists. If not, create it first. - Handle<JSRegExp> boilerplate; + // This function assumes that the boilerplate does not yet exist. + FeedbackSlot literal_slot(FeedbackVector::ToSlot(index)); Handle<Object> literal_site(vector->Get(literal_slot)->cast<Object>(), isolate); - if (!HasBoilerplate(literal_site)) { - ASSIGN_RETURN_FAILURE_ON_EXCEPTION( - isolate, boilerplate, - JSRegExp::New(isolate, pattern, JSRegExp::Flags(flags))); - if (IsUninitializedLiteralSite(*literal_site)) { - PreInitializeLiteralSite(vector, literal_slot); - return *boilerplate; - } - vector->Set(literal_slot, *boilerplate); + CHECK(!HasBoilerplate(literal_site)); + + Handle<JSRegExp> boilerplate; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, boilerplate, + JSRegExp::New(isolate, pattern, JSRegExp::Flags(flags))); + if (IsUninitializedLiteralSite(*literal_site)) { + PreInitializeLiteralSite(vector, literal_slot); + return *boilerplate; } + vector->Set(literal_slot, *boilerplate); return *JSRegExp::Copy(boilerplate); } diff --git a/deps/v8/src/runtime/runtime-object.cc b/deps/v8/src/runtime/runtime-object.cc index 310cdaab42..e07d91dd31 100644 --- a/deps/v8/src/runtime/runtime-object.cc +++ b/deps/v8/src/runtime/runtime-object.cc @@ -91,7 +91,7 @@ bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver, // (2) The property to be deleted must be the last property. int nof = receiver_map->NumberOfOwnDescriptors(); if (nof == 0) return false; - int descriptor = nof - 1; + InternalIndex descriptor(nof - 1); Handle<DescriptorArray> descriptors(receiver_map->instance_descriptors(), isolate); if (descriptors->GetKey(descriptor) != *key) return false; @@ -132,8 +132,12 @@ bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver, // for properties stored in the descriptor array. if (details.location() == kField) { DisallowHeapAllocation no_allocation; - isolate->heap()->NotifyObjectLayoutChange( - *receiver, receiver_map->instance_size(), no_allocation); + + // Invalidate slots manually later in case we delete an in-object tagged + // property. In this case we might later store an untagged value in the + // recorded slot. + isolate->heap()->NotifyObjectLayoutChange(*receiver, no_allocation, + InvalidateRecordedSlots::kNo); FieldIndex index = FieldIndex::ForPropertyIndex(*receiver_map, details.field_index()); // Special case deleting the last out-of object property. @@ -149,8 +153,13 @@ bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver, // Slot clearing is the reason why this entire function cannot currently // be implemented in the DeleteProperty stub. if (index.is_inobject() && !receiver_map->IsUnboxedDoubleField(index)) { + // We need to clear the recorded slot in this case because in-object + // slack tracking might not be finished. This ensures that we don't + // have recorded slots in free space. isolate->heap()->ClearRecordedSlot(*receiver, receiver->RawField(index.offset())); + MemoryChunk* chunk = MemoryChunk::FromHeapObject(*receiver); + chunk->InvalidateRecordedSlots(*receiver); } } } diff --git a/deps/v8/src/runtime/runtime-regexp.cc b/deps/v8/src/runtime/runtime-regexp.cc index e197e16e11..980339ee5e 100644 --- a/deps/v8/src/runtime/runtime-regexp.cc +++ b/deps/v8/src/runtime/runtime-regexp.cc @@ -613,20 +613,6 @@ V8_WARN_UNUSED_RESULT static Object StringReplaceGlobalRegExpWithString( JSRegExp::Type typeTag = regexp->TypeTag(); if (typeTag == JSRegExp::IRREGEXP) { - // Force tier up to native code for global replaces. The global replace is - // implemented differently for native code and bytecode execution, where the - // native code expects an array to store all the matches, and the bytecode - // matches one at a time, so it's easier to tier-up to native code from the - // start. - if (FLAG_regexp_tier_up) { - regexp->MarkTierUpForNextExec(); - if (FLAG_trace_regexp_tier_up) { - PrintF( - "Forcing tier-up of JSRegExp object %p in " - "StringReplaceGlobalRegExpWithString\n", - reinterpret_cast<void*>(regexp->ptr())); - } - } // Ensure the RegExp is compiled so we can access the capture-name map. if (RegExp::IrregexpPrepare(isolate, regexp, subject) == -1) { DCHECK(isolate->has_pending_exception()); @@ -1349,6 +1335,19 @@ V8_WARN_UNUSED_RESULT MaybeHandle<String> RegExpReplace( RETURN_ON_EXCEPTION(isolate, RegExpUtils::SetLastIndex(isolate, regexp, 0), String); + // Force tier up to native code for global replaces. The global replace is + // implemented differently for native code and bytecode execution, where the + // native code expects an array to store all the matches, and the bytecode + // matches one at a time, so it's easier to tier-up to native code from the + // start. + if (FLAG_regexp_tier_up && regexp->TypeTag() == JSRegExp::IRREGEXP) { + regexp->MarkTierUpForNextExec(); + if (FLAG_trace_regexp_tier_up) { + PrintF("Forcing tier-up of JSRegExp object %p in RegExpReplace\n", + reinterpret_cast<void*>(regexp->ptr())); + } + } + if (replace->length() == 0) { if (string->IsOneByteRepresentation()) { Object result = diff --git a/deps/v8/src/runtime/runtime-test.cc b/deps/v8/src/runtime/runtime-test.cc index a766dd5db2..a58b28ce52 100644 --- a/deps/v8/src/runtime/runtime-test.cc +++ b/deps/v8/src/runtime/runtime-test.cc @@ -32,6 +32,7 @@ #include "src/utils/ostreams.h" #include "src/wasm/memory-tracing.h" #include "src/wasm/module-compiler.h" +#include "src/wasm/wasm-code-manager.h" #include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-module.h" #include "src/wasm/wasm-objects-inl.h" @@ -676,6 +677,47 @@ RUNTIME_FUNCTION(Runtime_SetAllocationTimeout) { return ReadOnlyRoots(isolate).undefined_value(); } +namespace { + +int FixedArrayLenFromSize(int size) { + return Min((size - FixedArray::kHeaderSize) / kTaggedSize, + FixedArray::kMaxRegularLength); +} + +void FillUpOneNewSpacePage(Isolate* isolate, Heap* heap) { + NewSpace* space = heap->new_space(); + int space_remaining = static_cast<int>(*space->allocation_limit_address() - + *space->allocation_top_address()); + while (space_remaining > 0) { + int length = FixedArrayLenFromSize(space_remaining); + if (length > 0) { + Handle<FixedArray> padding = + isolate->factory()->NewFixedArray(length, AllocationType::kYoung); + DCHECK(heap->new_space()->Contains(*padding)); + space_remaining -= padding->Size(); + } else { + // Not enough room to create another fixed array. Create a filler. + heap->CreateFillerObjectAt(*heap->new_space()->allocation_top_address(), + space_remaining, ClearRecordedSlots::kNo); + break; + } + } +} + +} // namespace + +RUNTIME_FUNCTION(Runtime_SimulateNewspaceFull) { + HandleScope scope(isolate); + Heap* heap = isolate->heap(); + NewSpace* space = heap->new_space(); + PauseAllocationObserversScope pause_observers(heap); + AlwaysAllocateScope always_allocate(heap); + do { + FillUpOneNewSpacePage(isolate, heap); + } while (space->AddFreshPage()); + + return ReadOnlyRoots(isolate).undefined_value(); +} RUNTIME_FUNCTION(Runtime_DebugPrint) { SealHandleScope shs(isolate); @@ -1008,7 +1050,7 @@ RUNTIME_FUNCTION(Runtime_GetWasmRecoveredTrapCount) { RUNTIME_FUNCTION(Runtime_GetWasmExceptionId) { HandleScope scope(isolate); DCHECK_EQ(2, args.length()); - CONVERT_ARG_HANDLE_CHECKED(JSReceiver, exception, 0); + CONVERT_ARG_HANDLE_CHECKED(WasmExceptionPackage, exception, 0); CONVERT_ARG_HANDLE_CHECKED(WasmInstanceObject, instance, 1); Handle<Object> tag = WasmExceptionPackage::GetExceptionTag(isolate, exception); @@ -1024,7 +1066,7 @@ RUNTIME_FUNCTION(Runtime_GetWasmExceptionId) { RUNTIME_FUNCTION(Runtime_GetWasmExceptionValues) { HandleScope scope(isolate); DCHECK_EQ(1, args.length()); - CONVERT_ARG_HANDLE_CHECKED(JSReceiver, exception, 0); + CONVERT_ARG_HANDLE_CHECKED(WasmExceptionPackage, exception, 0); Handle<Object> values_obj = WasmExceptionPackage::GetExceptionValues(isolate, exception); CHECK(values_obj->IsFixedArray()); // Only called with correct input. @@ -1107,20 +1149,22 @@ RUNTIME_FUNCTION(Runtime_ArraySpeciesProtector) { RUNTIME_FUNCTION(Runtime_MapIteratorProtector) { SealHandleScope shs(isolate); DCHECK_EQ(0, args.length()); - return isolate->heap()->ToBoolean(isolate->IsMapIteratorLookupChainIntact()); + return isolate->heap()->ToBoolean( + Protectors::IsMapIteratorLookupChainIntact(isolate)); } RUNTIME_FUNCTION(Runtime_SetIteratorProtector) { SealHandleScope shs(isolate); DCHECK_EQ(0, args.length()); - return isolate->heap()->ToBoolean(isolate->IsSetIteratorLookupChainIntact()); + return isolate->heap()->ToBoolean( + Protectors::IsSetIteratorLookupChainIntact(isolate)); } RUNTIME_FUNCTION(Runtime_StringIteratorProtector) { SealHandleScope shs(isolate); DCHECK_EQ(0, args.length()); return isolate->heap()->ToBoolean( - isolate->IsStringIteratorLookupChainIntact()); + Protectors::IsStringIteratorLookupChainIntact(isolate)); } // Take a compiled wasm module and serialize it into an array buffer, which is @@ -1132,17 +1176,22 @@ RUNTIME_FUNCTION(Runtime_SerializeWasmModule) { wasm::NativeModule* native_module = module_obj->native_module(); wasm::WasmSerializer wasm_serializer(native_module); - size_t compiled_size = wasm_serializer.GetSerializedNativeModuleSize(); - void* array_data = isolate->array_buffer_allocator()->Allocate(compiled_size); - Handle<JSArrayBuffer> array_buffer = - isolate->factory()->NewJSArrayBuffer(SharedFlag::kNotShared); - JSArrayBuffer::Setup(array_buffer, isolate, false, array_data, compiled_size); - if (!array_data || - !wasm_serializer.SerializeNativeModule( - {reinterpret_cast<uint8_t*>(array_data), compiled_size})) { - return ReadOnlyRoots(isolate).undefined_value(); + size_t byte_length = wasm_serializer.GetSerializedNativeModuleSize(); + + MaybeHandle<JSArrayBuffer> result = + isolate->factory()->NewJSArrayBufferAndBackingStore( + byte_length, InitializedFlag::kUninitialized); + + Handle<JSArrayBuffer> array_buffer; + if (result.ToHandle(&array_buffer) && + wasm_serializer.SerializeNativeModule( + {reinterpret_cast<uint8_t*>(array_buffer->backing_store()), + byte_length})) { + return *array_buffer; } - return *array_buffer; + + // Error. Return undefined. + return ReadOnlyRoots(isolate).undefined_value(); } // Take an array buffer and attempt to reconstruct a compiled wasm module. @@ -1210,7 +1259,8 @@ RUNTIME_FUNCTION(Runtime_WasmGetNumberOfInstances) { DCHECK_EQ(1, args.length()); CONVERT_ARG_HANDLE_CHECKED(WasmModuleObject, module_obj, 0); int instance_count = 0; - WeakArrayList weak_instance_list = module_obj->weak_instance_list(); + WeakArrayList weak_instance_list = + module_obj->script().wasm_weak_instance_list(); for (int i = 0; i < weak_instance_list.length(); ++i) { if (weak_instance_list.Get(i)->IsWeak()) instance_count++; } @@ -1226,6 +1276,22 @@ RUNTIME_FUNCTION(Runtime_WasmNumInterpretedCalls) { return *isolate->factory()->NewNumberFromSize(static_cast<size_t>(num)); } +RUNTIME_FUNCTION(Runtime_WasmNumCodeSpaces) { + DCHECK_EQ(1, args.length()); + HandleScope scope(isolate); + CONVERT_ARG_HANDLE_CHECKED(JSObject, argument, 0); + Handle<WasmModuleObject> module; + if (argument->IsWasmInstanceObject()) { + module = handle(Handle<WasmInstanceObject>::cast(argument)->module_object(), + isolate); + } else if (argument->IsWasmModuleObject()) { + module = Handle<WasmModuleObject>::cast(argument); + } + size_t num_spaces = + module->native_module()->GetNumberOfCodeSpacesForTesting(); + return *isolate->factory()->NewNumberFromSize(num_spaces); +} + RUNTIME_FUNCTION(Runtime_RedirectToWasmInterpreter) { DCHECK_EQ(2, args.length()); HandleScope scope(isolate); diff --git a/deps/v8/src/runtime/runtime-typedarray.cc b/deps/v8/src/runtime/runtime-typedarray.cc index 7fab051cbf..327c102238 100644 --- a/deps/v8/src/runtime/runtime-typedarray.cc +++ b/deps/v8/src/runtime/runtime-typedarray.cc @@ -27,22 +27,7 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferDetach) { isolate, NewTypeError(MessageTemplate::kNotTypedArray)); } Handle<JSArrayBuffer> array_buffer = Handle<JSArrayBuffer>::cast(argument); - if (!array_buffer->is_detachable()) { - return ReadOnlyRoots(isolate).undefined_value(); - } - if (array_buffer->backing_store() == nullptr) { - CHECK_EQ(0, array_buffer->byte_length()); - return ReadOnlyRoots(isolate).undefined_value(); - } - // Shared array buffers should never be detached. - CHECK(!array_buffer->is_shared()); - DCHECK(!array_buffer->is_external()); - void* backing_store = array_buffer->backing_store(); - size_t byte_length = array_buffer->byte_length(); - array_buffer->set_is_external(true); - isolate->heap()->UnregisterArrayBuffer(*array_buffer); array_buffer->Detach(); - isolate->array_buffer_allocator()->Free(backing_store, byte_length); return ReadOnlyRoots(isolate).undefined_value(); } diff --git a/deps/v8/src/runtime/runtime-wasm.cc b/deps/v8/src/runtime/runtime-wasm.cc index 57e59c07be..b0153b7828 100644 --- a/deps/v8/src/runtime/runtime-wasm.cc +++ b/deps/v8/src/runtime/runtime-wasm.cc @@ -150,7 +150,12 @@ RUNTIME_FUNCTION(Runtime_WasmExceptionGetTag) { CONVERT_ARG_CHECKED(Object, except_obj_raw, 0); // TODO(mstarzinger): Manually box because parameters are not visited yet. Handle<Object> except_obj(except_obj_raw, isolate); - return *WasmExceptionPackage::GetExceptionTag(isolate, except_obj); + if (!except_obj->IsWasmExceptionPackage(isolate)) { + return ReadOnlyRoots(isolate).undefined_value(); + } + Handle<WasmExceptionPackage> exception = + Handle<WasmExceptionPackage>::cast(except_obj); + return *WasmExceptionPackage::GetExceptionTag(isolate, exception); } RUNTIME_FUNCTION(Runtime_WasmExceptionGetValues) { @@ -162,7 +167,12 @@ RUNTIME_FUNCTION(Runtime_WasmExceptionGetValues) { CONVERT_ARG_CHECKED(Object, except_obj_raw, 0); // TODO(mstarzinger): Manually box because parameters are not visited yet. Handle<Object> except_obj(except_obj_raw, isolate); - return *WasmExceptionPackage::GetExceptionValues(isolate, except_obj); + if (!except_obj->IsWasmExceptionPackage(isolate)) { + return ReadOnlyRoots(isolate).undefined_value(); + } + Handle<WasmExceptionPackage> exception = + Handle<WasmExceptionPackage>::cast(except_obj); + return *WasmExceptionPackage::GetExceptionValues(isolate, exception); } RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { diff --git a/deps/v8/src/runtime/runtime.h b/deps/v8/src/runtime/runtime.h index d705b05752..8319aabe2c 100644 --- a/deps/v8/src/runtime/runtime.h +++ b/deps/v8/src/runtime/runtime.h @@ -99,7 +99,7 @@ namespace internal { F(WeakCollectionSet, 4, 1) #define FOR_EACH_INTRINSIC_COMPILER(F, I) \ - F(CompileForOnStackReplacement, 1, 1) \ + F(CompileForOnStackReplacement, 0, 1) \ F(CompileLazy, 1, 1) \ F(CompileOptimized_Concurrent, 1, 1) \ F(CompileOptimized_NotConcurrent, 1, 1) \ @@ -319,7 +319,6 @@ namespace internal { F(ObjectValues, 1, 1) \ F(ObjectValuesSkipFastPath, 1, 1) \ F(OptimizeObjectForAddingMultipleProperties, 2, 1) \ - F(PerformSideEffectCheckForObject, 1, 1) \ F(SetDataProperties, 2, 1) \ F(SetKeyedProperty, 3, 1) \ F(SetNamedProperty, 3, 1) \ @@ -515,6 +514,7 @@ namespace internal { F(SetWasmCompileControls, 2, 1) \ F(SetWasmInstantiateControls, 0, 1) \ F(SetWasmThreadsEnabled, 1, 1) \ + F(SimulateNewspaceFull, 0, 1) \ F(StringIteratorProtector, 0, 1) \ F(SystemBreak, 0, 1) \ F(TraceEnter, 0, 1) \ @@ -523,6 +523,7 @@ namespace internal { F(UnblockConcurrentRecompilation, 0, 1) \ F(WasmGetNumberOfInstances, 1, 1) \ F(WasmNumInterpretedCalls, 1, 1) \ + F(WasmNumCodeSpaces, 1, 1) \ F(WasmTierUpFunction, 2, 1) \ F(WasmTraceMemory, 1, 1) \ I(DeoptimizeNow, 0, 1) |