diff options
author | Myles Borins <mylesborins@google.com> | 2017-08-01 11:36:44 -0500 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2017-08-01 15:23:15 -0500 |
commit | 0a66b223e149a841669bfad5598e4254589730cb (patch) | |
tree | 5ec050f7f78aafbf5b1e0e50d639fb843141e162 /deps/v8/src/runtime | |
parent | 1782b3836ba58ef0da6b687f2bb970c0bd8199ad (diff) | |
download | node-new-0a66b223e149a841669bfad5598e4254589730cb.tar.gz |
deps: update V8 to 6.0.286.52
PR-URL: https://github.com/nodejs/node/pull/14004
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/src/runtime')
-rw-r--r-- | deps/v8/src/runtime/runtime-array.cc | 38 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-classes.cc | 9 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-collections.cc | 43 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-compiler.cc | 33 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-debug.cc | 18 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-function.cc | 8 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-generator.cc | 13 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-internal.cc | 19 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-interpreter.cc | 15 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-intl.cc (renamed from deps/v8/src/runtime/runtime-i18n.cc) | 46 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-literals.cc | 116 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-object.cc | 120 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-regexp.cc | 4 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-strings.cc | 6 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-test.cc | 52 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-typedarray.cc | 39 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime-wasm.cc | 4 | ||||
-rw-r--r-- | deps/v8/src/runtime/runtime.h | 174 |
18 files changed, 480 insertions, 277 deletions
diff --git a/deps/v8/src/runtime/runtime-array.cc b/deps/v8/src/runtime/runtime-array.cc index 97432b6ef1..781065a371 100644 --- a/deps/v8/src/runtime/runtime-array.cc +++ b/deps/v8/src/runtime/runtime-array.cc @@ -52,14 +52,14 @@ RUNTIME_FUNCTION(Runtime_SpecialArrayFunctions) { Handle<JSObject> holder = isolate->factory()->NewJSObject(isolate->object_function()); - InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); + InstallBuiltin(isolate, holder, "pop", Builtins::kFastArrayPop); InstallBuiltin(isolate, holder, "push", Builtins::kFastArrayPush); - InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); + InstallBuiltin(isolate, holder, "shift", Builtins::kFastArrayShift); InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); - InstallBuiltin(isolate, holder, "includes", Builtins::kArrayIncludes, 2); - InstallBuiltin(isolate, holder, "indexOf", Builtins::kArrayIndexOf, 2); + InstallBuiltin(isolate, holder, "includes", Builtins::kArrayIncludes); + InstallBuiltin(isolate, holder, "indexOf", Builtins::kArrayIndexOf); InstallBuiltin(isolate, holder, "keys", Builtins::kArrayPrototypeKeys, 0, kArrayKeys); InstallBuiltin(isolate, holder, "values", Builtins::kArrayPrototypeValues, 0, @@ -142,14 +142,14 @@ RUNTIME_FUNCTION(Runtime_MoveArrayContents) { // How many elements does this object/array have? RUNTIME_FUNCTION(Runtime_EstimateNumberOfElements) { + DisallowHeapAllocation no_gc; HandleScope scope(isolate); DCHECK_EQ(1, args.length()); - CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); - Handle<FixedArrayBase> elements(array->elements(), isolate); + CONVERT_ARG_CHECKED(JSArray, array, 0); + FixedArrayBase* elements = array->elements(); SealHandleScope shs(isolate); if (elements->IsDictionary()) { - int result = - Handle<SeededNumberDictionary>::cast(elements)->NumberOfElements(); + int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); return Smi::FromInt(result); } else { DCHECK(array->length()->IsSmi()); @@ -531,16 +531,10 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) { CONVERT_ARG_HANDLE_CHECKED(Object, from_index, 2); // Let O be ? ToObject(this value). - Handle<Object> receiver_obj = args.at(0); - if (receiver_obj->IsNullOrUndefined(isolate)) { - THROW_NEW_ERROR_RETURN_FAILURE( - isolate, NewTypeError(MessageTemplate::kCalledOnNullOrUndefined, - isolate->factory()->NewStringFromAsciiChecked( - "Array.prototype.indexOf"))); - } Handle<JSReceiver> object; - ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, object, - Object::ToObject(isolate, args.at(0))); + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, object, + Object::ToObject(isolate, args.at(0), "Array.prototype.indexOf")); // Let len be ? ToLength(? Get(O, "length")). int64_t len; @@ -574,7 +568,13 @@ RUNTIME_FUNCTION(Runtime_ArrayIndexOf) { Object::ToInteger(isolate, from_index)); double fp = from_index->Number(); if (fp > len) return Smi::FromInt(-1); - start_from = static_cast<int64_t>(fp); + if (V8_LIKELY(fp >= + static_cast<double>(std::numeric_limits<int64_t>::min()))) { + DCHECK(fp < std::numeric_limits<int64_t>::max()); + start_from = static_cast<int64_t>(fp); + } else { + start_from = std::numeric_limits<int64_t>::min(); + } } int64_t index; @@ -661,7 +661,7 @@ RUNTIME_FUNCTION(Runtime_SpreadIterableFixed) { Handle<FixedArray> result = isolate->factory()->NewFixedArray(spread_length); ElementsAccessor* accessor = spread_array->GetElementsAccessor(); for (uint32_t i = 0; i < spread_length; i++) { - DCHECK(accessor->HasElement(spread_array, i)); + DCHECK(accessor->HasElement(*spread_array, i)); Handle<Object> element = accessor->Get(spread_array, i); result->set(i, *element); } diff --git a/deps/v8/src/runtime/runtime-classes.cc b/deps/v8/src/runtime/runtime-classes.cc index 7dadca5026..feb0120045 100644 --- a/deps/v8/src/runtime/runtime-classes.cc +++ b/deps/v8/src/runtime/runtime-classes.cc @@ -149,15 +149,6 @@ static MaybeHandle<Object> DefineClass(Isolate* isolate, map->SetConstructor(*constructor); Handle<JSObject> prototype = isolate->factory()->NewJSObjectFromMap(map); - if (!super_class->IsTheHole(isolate)) { - // Derived classes, just like builtins, don't create implicit receivers in - // [[construct]]. Instead they just set up new.target and call into the - // constructor. Hence we can reuse the builtins construct stub for derived - // classes. - Handle<Code> stub(isolate->builtins()->JSBuiltinsConstructStubForDerived()); - constructor->shared()->SetConstructStub(*stub); - } - JSFunction::SetPrototype(constructor, prototype); PropertyAttributes attribs = static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); diff --git a/deps/v8/src/runtime/runtime-collections.cc b/deps/v8/src/runtime/runtime-collections.cc index 214ce1c4e6..0e311517e9 100644 --- a/deps/v8/src/runtime/runtime-collections.cc +++ b/deps/v8/src/runtime/runtime-collections.cc @@ -325,5 +325,48 @@ RUNTIME_FUNCTION(Runtime_GetWeakSetValues) { CHECK(max_values >= 0); return *JSWeakCollection::GetEntries(holder, max_values); } + +RUNTIME_FUNCTION(Runtime_IsJSMap) { + SealHandleScope shs(isolate); + DCHECK_EQ(1, args.length()); + CONVERT_ARG_CHECKED(Object, obj, 0); + return isolate->heap()->ToBoolean(obj->IsJSMap()); +} + +RUNTIME_FUNCTION(Runtime_IsJSSet) { + SealHandleScope shs(isolate); + DCHECK_EQ(1, args.length()); + CONVERT_ARG_CHECKED(Object, obj, 0); + return isolate->heap()->ToBoolean(obj->IsJSSet()); +} + +RUNTIME_FUNCTION(Runtime_IsJSMapIterator) { + SealHandleScope shs(isolate); + DCHECK_EQ(1, args.length()); + CONVERT_ARG_CHECKED(Object, obj, 0); + return isolate->heap()->ToBoolean(obj->IsJSMapIterator()); +} + +RUNTIME_FUNCTION(Runtime_IsJSSetIterator) { + SealHandleScope shs(isolate); + DCHECK_EQ(1, args.length()); + CONVERT_ARG_CHECKED(Object, obj, 0); + return isolate->heap()->ToBoolean(obj->IsJSSetIterator()); +} + +RUNTIME_FUNCTION(Runtime_IsJSWeakMap) { + SealHandleScope shs(isolate); + DCHECK_EQ(1, args.length()); + CONVERT_ARG_CHECKED(Object, obj, 0); + return isolate->heap()->ToBoolean(obj->IsJSWeakMap()); +} + +RUNTIME_FUNCTION(Runtime_IsJSWeakSet) { + SealHandleScope shs(isolate); + DCHECK_EQ(1, args.length()); + CONVERT_ARG_CHECKED(Object, obj, 0); + return isolate->heap()->ToBoolean(obj->IsJSWeakSet()); +} + } // namespace internal } // namespace v8 diff --git a/deps/v8/src/runtime/runtime-compiler.cc b/deps/v8/src/runtime/runtime-compiler.cc index b7151f83c6..7b73967acc 100644 --- a/deps/v8/src/runtime/runtime-compiler.cc +++ b/deps/v8/src/runtime/runtime-compiler.cc @@ -68,6 +68,17 @@ RUNTIME_FUNCTION(Runtime_CompileOptimized_NotConcurrent) { return function->code(); } +RUNTIME_FUNCTION(Runtime_EvictOptimizedCodeSlot) { + SealHandleScope scope(isolate); + DCHECK_EQ(1, args.length()); + CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); + + DCHECK(function->is_compiled()); + function->feedback_vector()->EvictOptimizedCodeMarkedForDeoptimization( + function->shared(), "Runtime_EvictOptimizedCodeSlot"); + return function->code(); +} + RUNTIME_FUNCTION(Runtime_InstantiateAsmJs) { HandleScope scope(isolate); DCHECK_EQ(args.length(), 4); @@ -85,12 +96,11 @@ RUNTIME_FUNCTION(Runtime_InstantiateAsmJs) { if (args[3]->IsJSArrayBuffer()) { memory = args.at<JSArrayBuffer>(3); } - if (function->shared()->HasAsmWasmData() && - AsmJs::IsStdlibValid(isolate, handle(function->shared()->asm_wasm_data()), - stdlib)) { - MaybeHandle<Object> result; - result = AsmJs::InstantiateAsmWasm( - isolate, handle(function->shared()->asm_wasm_data()), memory, foreign); + if (function->shared()->HasAsmWasmData()) { + Handle<SharedFunctionInfo> shared(function->shared()); + Handle<FixedArray> data(shared->asm_wasm_data()); + MaybeHandle<Object> result = AsmJs::InstantiateAsmWasm( + isolate, shared, data, stdlib, foreign, memory); if (!result.is_null()) { return *result.ToHandleChecked(); } @@ -205,8 +215,15 @@ RUNTIME_FUNCTION(Runtime_NotifyDeoptimized) { // Evict optimized code for this function from the cache so that it // doesn't get used for new closures. - function->shared()->EvictFromOptimizedCodeMap(*optimized_code, - "notify deoptimized"); + if (function->feedback_vector()->optimized_code() == *optimized_code) { + function->ClearOptimizedCodeSlot("notify deoptimized"); + } + // Remove the code from the osr optimized code cache. + DeoptimizationInputData* deopt_data = + DeoptimizationInputData::cast(optimized_code->deoptimization_data()); + if (deopt_data->OsrAstId()->value() == BailoutId::None().ToInt()) { + isolate->EvictOSROptimizedCode(*optimized_code, "notify deoptimized"); + } } else { // TODO(titzer): we should probably do DeoptimizeCodeList(code) // unconditionally if the code is not already marked for deoptimization. diff --git a/deps/v8/src/runtime/runtime-debug.cc b/deps/v8/src/runtime/runtime-debug.cc index a13d3f95cc..b65757b2de 100644 --- a/deps/v8/src/runtime/runtime-debug.cc +++ b/deps/v8/src/runtime/runtime-debug.cc @@ -551,7 +551,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) { // bit 0: invoked in the debugger context. // bit 1: optimized frame. // bit 2: inlined in optimized frame - int flags = 0; + int flags = inlined_frame_index << 2; if (*save->context() == *isolate->debug()->debug_context()) { flags |= 1 << 0; } @@ -830,7 +830,7 @@ RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) { CHECK(isolate->debug()->CheckExecutionState(break_id)); CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); - CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); + CONVERT_NUMBER_CHECKED(int, inlined_frame_index, Int32, args[2]); ScopeIterator::Option option = ScopeIterator::DEFAULT; if (args.length() == 4) { @@ -842,9 +842,19 @@ RUNTIME_FUNCTION(Runtime_GetAllScopesDetails) { StackFrame::Id id = DebugFrameHelper::UnwrapFrameId(wrapped_id); StackTraceFrameIterator frame_it(isolate, id); StandardFrame* frame = frame_it.frame(); - FrameInspector frame_inspector(frame, inlined_jsframe_index, isolate); - List<Handle<JSObject> > result(4); + // Handle wasm frames specially. They provide exactly two scopes (global / + // local). + if (frame->is_wasm_interpreter_entry()) { + Handle<WasmDebugInfo> debug_info( + WasmInterpreterEntryFrame::cast(frame)->wasm_instance()->debug_info(), + isolate); + return *WasmDebugInfo::GetScopeDetails(debug_info, frame->fp(), + inlined_frame_index); + } + + FrameInspector frame_inspector(frame, inlined_frame_index, isolate); + List<Handle<JSObject>> result(4); ScopeIterator it(isolate, &frame_inspector, option); for (; !it.Done(); it.Next()) { Handle<JSObject> details; diff --git a/deps/v8/src/runtime/runtime-function.cc b/deps/v8/src/runtime/runtime-function.cc index ac8a430761..c7100d1bf5 100644 --- a/deps/v8/src/runtime/runtime-function.cc +++ b/deps/v8/src/runtime/runtime-function.cc @@ -111,8 +111,7 @@ RUNTIME_FUNCTION(Runtime_FunctionGetContextData) { DCHECK_EQ(1, args.length()); CONVERT_ARG_CHECKED(JSFunction, fun, 0); - FixedArray* array = fun->native_context()->embedder_data(); - return array->get(v8::Context::kDebugIdIndex); + return fun->native_context()->debug_context_id(); } RUNTIME_FUNCTION(Runtime_FunctionSetInstanceClassName) { @@ -145,8 +144,7 @@ RUNTIME_FUNCTION(Runtime_FunctionSetPrototype) { CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); CHECK(fun->IsConstructor()); - RETURN_FAILURE_ON_EXCEPTION(isolate, - Accessors::FunctionSetPrototype(fun, value)); + JSFunction::SetPrototype(fun, value); return args[0]; // return TOS } @@ -189,7 +187,7 @@ RUNTIME_FUNCTION(Runtime_SetCode) { } target_shared->set_scope_info(source_shared->scope_info()); target_shared->set_outer_scope_info(source_shared->outer_scope_info()); - target_shared->set_length(source_shared->length()); + target_shared->set_length(source_shared->GetLength()); target_shared->set_feedback_metadata(source_shared->feedback_metadata()); target_shared->set_internal_formal_parameter_count( source_shared->internal_formal_parameter_count()); diff --git a/deps/v8/src/runtime/runtime-generator.cc b/deps/v8/src/runtime/runtime-generator.cc index 0c8fe6db01..74b1fe90d2 100644 --- a/deps/v8/src/runtime/runtime-generator.cc +++ b/deps/v8/src/runtime/runtime-generator.cc @@ -66,6 +66,10 @@ RUNTIME_FUNCTION(Runtime_GeneratorGetContext) { DCHECK_EQ(1, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); + // Runtime call is implemented in InterpreterIntrinsics and lowered in + // JSIntrinsicLowering + UNREACHABLE(); + return generator->context(); } @@ -74,6 +78,10 @@ RUNTIME_FUNCTION(Runtime_GeneratorGetInputOrDebugPos) { DCHECK_EQ(1, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); + // Runtime call is implemented in InterpreterIntrinsics and lowered in + // JSIntrinsicLowering + UNREACHABLE(); + return generator->input_or_debug_pos(); } @@ -81,7 +89,6 @@ RUNTIME_FUNCTION(Runtime_AsyncGeneratorGetAwaitInputOrDebugPos) { HandleScope scope(isolate); DCHECK_EQ(1, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSAsyncGeneratorObject, generator, 0); - return generator->await_input_or_debug_pos(); } @@ -112,6 +119,10 @@ RUNTIME_FUNCTION(Runtime_GeneratorGetResumeMode) { DCHECK_EQ(1, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); + // Runtime call is implemented in InterpreterIntrinsics and lowered in + // JSIntrinsicLowering + UNREACHABLE(); + return Smi::FromInt(generator->resume_mode()); } diff --git a/deps/v8/src/runtime/runtime-internal.cc b/deps/v8/src/runtime/runtime-internal.cc index 8c566c081d..7348d5f007 100644 --- a/deps/v8/src/runtime/runtime-internal.cc +++ b/deps/v8/src/runtime/runtime-internal.cc @@ -288,14 +288,6 @@ RUNTIME_FUNCTION(Runtime_ThrowNotConstructor) { isolate, NewTypeError(MessageTemplate::kNotConstructor, object)); } -RUNTIME_FUNCTION(Runtime_ThrowNotGeneric) { - HandleScope scope(isolate); - DCHECK_EQ(1, args.length()); - CONVERT_ARG_HANDLE_CHECKED(Object, arg0, 0); - THROW_NEW_ERROR_RETURN_FAILURE( - isolate, NewTypeError(MessageTemplate::kNotGeneric, arg0)); -} - RUNTIME_FUNCTION(Runtime_ThrowGeneratorRunning) { HandleScope scope(isolate); DCHECK_EQ(0, args.length()); @@ -455,11 +447,18 @@ RUNTIME_FUNCTION(Runtime_ThrowConstructedNonConstructable) { isolate, NewTypeError(MessageTemplate::kNotConstructor, callsite)); } -RUNTIME_FUNCTION(Runtime_ThrowDerivedConstructorReturnedNonObject) { +RUNTIME_FUNCTION(Runtime_ThrowConstructorReturnedNonObject) { HandleScope scope(isolate); DCHECK_EQ(0, args.length()); + if (FLAG_harmony_restrict_constructor_return) { + THROW_NEW_ERROR_RETURN_FAILURE( + isolate, + NewTypeError(MessageTemplate::kClassConstructorReturnedNonObject)); + } + THROW_NEW_ERROR_RETURN_FAILURE( - isolate, NewTypeError(MessageTemplate::kDerivedConstructorReturn)); + isolate, + NewTypeError(MessageTemplate::kDerivedConstructorReturnedNonObject)); } RUNTIME_FUNCTION(Runtime_ThrowUndefinedOrNullToObject) { diff --git a/deps/v8/src/runtime/runtime-interpreter.cc b/deps/v8/src/runtime/runtime-interpreter.cc index 9f3897bf64..5889a477c3 100644 --- a/deps/v8/src/runtime/runtime-interpreter.cc +++ b/deps/v8/src/runtime/runtime-interpreter.cc @@ -34,6 +34,8 @@ RUNTIME_FUNCTION(Runtime_InterpreterNewClosure) { static_cast<PretenureFlag>(pretenured_flag)); } +#ifdef V8_TRACE_IGNITION + namespace { void AdvanceToOffsetForTracing( @@ -109,17 +111,22 @@ void PrintRegisters(std::ostream& os, bool is_input, } // namespace RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeEntry) { + if (!FLAG_trace_ignition) { + return isolate->heap()->undefined_value(); + } + SealHandleScope shs(isolate); DCHECK_EQ(3, args.length()); CONVERT_ARG_HANDLE_CHECKED(BytecodeArray, bytecode_array, 0); CONVERT_SMI_ARG_CHECKED(bytecode_offset, 1); CONVERT_ARG_HANDLE_CHECKED(Object, accumulator, 2); - OFStream os(stdout); int offset = bytecode_offset - BytecodeArray::kHeaderSize + kHeapObjectTag; interpreter::BytecodeArrayIterator bytecode_iterator(bytecode_array); AdvanceToOffsetForTracing(bytecode_iterator, offset); if (offset == bytecode_iterator.current_offset()) { + OFStream os(stdout); + // Print bytecode. const uint8_t* base_address = bytecode_array->GetFirstBytecodeAddress(); const uint8_t* bytecode_address = base_address + offset; @@ -137,6 +144,10 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeEntry) { } RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) { + if (!FLAG_trace_ignition) { + return isolate->heap()->undefined_value(); + } + SealHandleScope shs(isolate); DCHECK_EQ(3, args.length()); CONVERT_ARG_HANDLE_CHECKED(BytecodeArray, bytecode_array, 0); @@ -160,6 +171,8 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) { return isolate->heap()->undefined_value(); } +#endif + RUNTIME_FUNCTION(Runtime_InterpreterAdvanceBytecodeOffset) { SealHandleScope shs(isolate); DCHECK_EQ(2, args.length()); diff --git a/deps/v8/src/runtime/runtime-i18n.cc b/deps/v8/src/runtime/runtime-intl.cc index 80c8a9cd01..623fe05fe8 100644 --- a/deps/v8/src/runtime/runtime-i18n.cc +++ b/deps/v8/src/runtime/runtime-intl.cc @@ -2,8 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#ifndef V8_INTL_SUPPORT +#error Internationalization is expected to be enabled. +#endif // V8_INTL_SUPPORT -#ifdef V8_I18N_SUPPORT #include "src/runtime/runtime-utils.h" #include <memory> @@ -12,9 +14,10 @@ #include "src/api.h" #include "src/arguments.h" #include "src/factory.h" -#include "src/i18n.h" +#include "src/intl.h" #include "src/isolate-inl.h" #include "src/messages.h" +#include "src/objects/intl-objects.h" #include "src/utils.h" #include "unicode/brkiter.h" @@ -41,9 +44,12 @@ #include "unicode/uloc.h" #include "unicode/unistr.h" #include "unicode/unum.h" -#include "unicode/ustring.h" +#include "unicode/uvernum.h" #include "unicode/uversion.h" +#if U_ICU_VERSION_MAJOR_NUM >= 59 +#include "unicode/char16ptr.h" +#endif namespace v8 { namespace internal { @@ -85,7 +91,6 @@ RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) { return *factory->NewStringFromAsciiChecked(result); } - RUNTIME_FUNCTION(Runtime_AvailableLocalesOf) { HandleScope scope(isolate); Factory* factory = isolate->factory(); @@ -130,7 +135,6 @@ RUNTIME_FUNCTION(Runtime_AvailableLocalesOf) { return *locales; } - RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) { HandleScope scope(isolate); Factory* factory = isolate->factory(); @@ -151,7 +155,6 @@ RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) { return *factory->NewStringFromStaticChars("und"); } - RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) { HandleScope scope(isolate); Factory* factory = isolate->factory(); @@ -236,7 +239,6 @@ RUNTIME_FUNCTION(Runtime_GetLanguageTagVariants) { return *result; } - RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) { HandleScope scope(isolate); @@ -252,7 +254,6 @@ RUNTIME_FUNCTION(Runtime_IsInitializedIntlObject) { return isolate->heap()->ToBoolean(!tag->IsUndefined(isolate)); } - RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) { HandleScope scope(isolate); @@ -270,7 +271,6 @@ RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) { String::cast(*tag)->Equals(*expected_type)); } - RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) { HandleScope scope(isolate); @@ -285,7 +285,6 @@ RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) { return isolate->heap()->undefined_value(); } - RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { HandleScope scope(isolate); @@ -318,7 +317,6 @@ RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) { return *local_object; } - RUNTIME_FUNCTION(Runtime_InternalDateFormat) { HandleScope scope(isolate); @@ -406,9 +404,10 @@ bool AddElement(Handle<JSArray> array, int index, int32_t field_id, icu::UnicodeString field(formatted.tempSubStringBetween(begin, end)); ASSIGN_RETURN_ON_EXCEPTION_VALUE( - isolate, value, factory->NewStringFromTwoByte(Vector<const uint16_t>( - reinterpret_cast<const uint16_t*>(field.getBuffer()), - field.length())), + isolate, value, + factory->NewStringFromTwoByte(Vector<const uint16_t>( + reinterpret_cast<const uint16_t*>(field.getBuffer()), + field.length())), false); JSObject::AddProperty(element, factory->value_string(), value, NONE); @@ -507,7 +506,6 @@ RUNTIME_FUNCTION(Runtime_CreateNumberFormat) { return *local_object; } - RUNTIME_FUNCTION(Runtime_InternalNumberFormat) { HandleScope scope(isolate); @@ -587,7 +585,6 @@ RUNTIME_FUNCTION(Runtime_CreateCollator) { return *local_object; } - RUNTIME_FUNCTION(Runtime_InternalCompare) { HandleScope scope(isolate); @@ -624,7 +621,6 @@ RUNTIME_FUNCTION(Runtime_InternalCompare) { return *isolate->factory()->NewNumberFromInt(result); } - RUNTIME_FUNCTION(Runtime_CreateBreakIterator) { HandleScope scope(isolate); @@ -660,7 +656,6 @@ RUNTIME_FUNCTION(Runtime_CreateBreakIterator) { return *local_object; } - RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) { HandleScope scope(isolate); @@ -691,7 +686,6 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorAdoptText) { return isolate->heap()->undefined_value(); } - RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) { HandleScope scope(isolate); @@ -706,7 +700,6 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorFirst) { return *isolate->factory()->NewNumberFromInt(break_iterator->first()); } - RUNTIME_FUNCTION(Runtime_BreakIteratorNext) { HandleScope scope(isolate); @@ -721,7 +714,6 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorNext) { return *isolate->factory()->NewNumberFromInt(break_iterator->next()); } - RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) { HandleScope scope(isolate); @@ -736,7 +728,6 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorCurrent) { return *isolate->factory()->NewNumberFromInt(break_iterator->current()); } - RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) { HandleScope scope(isolate); @@ -768,7 +759,7 @@ RUNTIME_FUNCTION(Runtime_BreakIteratorBreakType) { } } -RUNTIME_FUNCTION(Runtime_StringToLowerCaseI18N) { +RUNTIME_FUNCTION(Runtime_StringToLowerCaseIntl) { HandleScope scope(isolate); DCHECK_EQ(args.length(), 1); CONVERT_ARG_HANDLE_CHECKED(String, s, 0); @@ -776,7 +767,7 @@ RUNTIME_FUNCTION(Runtime_StringToLowerCaseI18N) { return ConvertToLower(s, isolate); } -RUNTIME_FUNCTION(Runtime_StringToUpperCaseI18N) { +RUNTIME_FUNCTION(Runtime_StringToUpperCaseIntl) { HandleScope scope(isolate); DCHECK_EQ(args.length(), 1); CONVERT_ARG_HANDLE_CHECKED(String, s, 0); @@ -798,7 +789,10 @@ RUNTIME_FUNCTION(Runtime_StringLocaleConvertCase) { s = String::Flatten(s); // All the languages requiring special-handling have two-letter codes. - if (V8_UNLIKELY(lang_arg->length() > 2)) + // Note that we have to check for '!= 2' here because private-use language + // tags (x-foo) or grandfathered irregular tags (e.g. i-enochian) would have + // only 'x' or 'i' when they get here. + if (V8_UNLIKELY(lang_arg->length() != 2)) return ConvertCase(s, is_upper, isolate); char c1, c2; @@ -843,5 +837,3 @@ RUNTIME_FUNCTION(Runtime_DateCacheVersion) { } // namespace internal } // namespace v8 - -#endif // V8_I18N_SUPPORT diff --git a/deps/v8/src/runtime/runtime-literals.cc b/deps/v8/src/runtime/runtime-literals.cc index 7beadf5e0b..1a2b1f584e 100644 --- a/deps/v8/src/runtime/runtime-literals.cc +++ b/deps/v8/src/runtime/runtime-literals.cc @@ -14,65 +14,56 @@ namespace v8 { namespace internal { -static Handle<Map> ComputeObjectLiteralMap( - Handle<Context> context, - Handle<BoilerplateDescription> boilerplate_description, - bool* is_result_from_cache) { - int number_of_properties = boilerplate_description->backing_store_size(); - Isolate* isolate = context->GetIsolate(); - return isolate->factory()->ObjectLiteralMapFromCache( - context, number_of_properties, is_result_from_cache); -} - MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( Isolate* isolate, Handle<FeedbackVector> vector, - Handle<BoilerplateDescription> boilerplate_description); + Handle<FixedArray> compile_time_value); MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( Isolate* isolate, Handle<FeedbackVector> vector, Handle<BoilerplateDescription> boilerplate_description, - bool should_have_fast_elements) { - Handle<Context> context = isolate->native_context(); + bool use_fast_elements, bool has_null_prototype) { + Handle<Context> native_context = isolate->native_context(); // In case we have function literals, we want the object to be in // slow properties mode for now. We don't go in the map cache because // maps with constant functions can't be shared if the functions are // not the same (which is the common case). - bool is_result_from_cache = false; - Handle<Map> map = ComputeObjectLiteralMap(context, boilerplate_description, - &is_result_from_cache); + int number_of_properties = boilerplate_description->backing_store_size(); + + // Ignoring number_of_properties for force dictionary map with __proto__:null. + Handle<Map> map = + has_null_prototype + ? handle(native_context->slow_object_with_null_prototype_map(), + isolate) + : isolate->factory()->ObjectLiteralMapFromCache(native_context, + number_of_properties); PretenureFlag pretenure_flag = isolate->heap()->InNewSpace(*vector) ? NOT_TENURED : TENURED; Handle<JSObject> boilerplate = - isolate->factory()->NewJSObjectFromMap(map, pretenure_flag); + map->is_dictionary_map() + ? isolate->factory()->NewSlowJSObjectFromMap( + map, number_of_properties, pretenure_flag) + : isolate->factory()->NewJSObjectFromMap(map, pretenure_flag); // Normalize the elements of the boilerplate to save space if needed. - if (!should_have_fast_elements) JSObject::NormalizeElements(boilerplate); + if (!use_fast_elements) JSObject::NormalizeElements(boilerplate); // Add the constant properties to the boilerplate. int length = boilerplate_description->size(); - bool should_transform = - !is_result_from_cache && boilerplate->HasFastProperties(); - bool should_normalize = should_transform; - if (should_normalize) { - // TODO(verwaest): We might not want to ever normalize here. - JSObject::NormalizeProperties(boilerplate, KEEP_INOBJECT_PROPERTIES, length, - "Boilerplate"); - } // TODO(verwaest): Support tracking representations in the boilerplate. for (int index = 0; index < length; index++) { Handle<Object> key(boilerplate_description->name(index), isolate); Handle<Object> value(boilerplate_description->value(index), isolate); - if (value->IsBoilerplateDescription()) { - // The value contains the boilerplate properties of a - // simple object or array literal. - Handle<BoilerplateDescription> boilerplate = - Handle<BoilerplateDescription>::cast(value); + if (value->IsFixedArray()) { + // The value contains the CompileTimeValue with the boilerplate properties + // of a simple object or array literal. + Handle<FixedArray> compile_time_value = Handle<FixedArray>::cast(value); ASSIGN_RETURN_ON_EXCEPTION( isolate, value, - CreateLiteralBoilerplate(isolate, vector, boilerplate), Object); + CreateLiteralBoilerplate(isolate, vector, compile_time_value), + Object); } MaybeHandle<Object> maybe_result; uint32_t element_index = 0; @@ -92,11 +83,9 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( RETURN_ON_EXCEPTION(isolate, maybe_result, Object); } - // Transform to fast properties if necessary. For object literals with - // containing function literals we defer this operation until after all - // computed properties have been assigned so that we can generate - // constant function properties. - if (should_transform) { + if (map->is_dictionary_map() && !has_null_prototype) { + // TODO(cbruni): avoid making the boilerplate fast again, the clone stub + // supports dict-mode objects directly. JSObject::MigrateSlowToFast(boilerplate, boilerplate->map()->unused_property_fields(), "FastLiteral"); @@ -154,15 +143,16 @@ static MaybeHandle<Object> CreateArrayLiteralBoilerplate( copied_elements_values = fixed_array_values_copy; FOR_WITH_HANDLE_SCOPE( isolate, int, i = 0, i, i < fixed_array_values->length(), i++, { - if (fixed_array_values->get(i)->IsBoilerplateDescription()) { - // The value contains the boilerplate properties of a - // simple object or array literal. - Handle<BoilerplateDescription> boilerplate( - BoilerplateDescription::cast(fixed_array_values->get(i))); + if (fixed_array_values->get(i)->IsFixedArray()) { + // The value contains the CompileTimeValue with the + // boilerplate description of a simple object or + // array literal. + Handle<FixedArray> compile_time_value( + FixedArray::cast(fixed_array_values->get(i))); Handle<Object> result; ASSIGN_RETURN_ON_EXCEPTION( isolate, result, - CreateLiteralBoilerplate(isolate, vector, boilerplate), + CreateLiteralBoilerplate(isolate, vector, compile_time_value), Object); fixed_array_values_copy->set(i, *result); } @@ -178,28 +168,21 @@ static MaybeHandle<Object> CreateArrayLiteralBoilerplate( MUST_USE_RESULT static MaybeHandle<Object> CreateLiteralBoilerplate( Isolate* isolate, Handle<FeedbackVector> vector, - Handle<BoilerplateDescription> array) { - Handle<HeapObject> elements = CompileTimeValue::GetElements(array); - switch (CompileTimeValue::GetLiteralType(array)) { - case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS: { - Handle<BoilerplateDescription> props = - Handle<BoilerplateDescription>::cast(elements); - return CreateObjectLiteralBoilerplate(isolate, vector, props, true); - } - case CompileTimeValue::OBJECT_LITERAL_SLOW_ELEMENTS: { - Handle<BoilerplateDescription> props = - Handle<BoilerplateDescription>::cast(elements); - return CreateObjectLiteralBoilerplate(isolate, vector, props, false); - } - case CompileTimeValue::ARRAY_LITERAL: { - Handle<ConstantElementsPair> elems = - Handle<ConstantElementsPair>::cast(elements); - return CreateArrayLiteralBoilerplate(isolate, vector, elems); - } - default: - UNREACHABLE(); - return MaybeHandle<Object>(); + Handle<FixedArray> compile_time_value) { + Handle<HeapObject> elements = + CompileTimeValue::GetElements(compile_time_value); + int flags = CompileTimeValue::GetLiteralTypeFlags(compile_time_value); + if (flags == CompileTimeValue::kArrayLiteralFlag) { + Handle<ConstantElementsPair> elems = + Handle<ConstantElementsPair>::cast(elements); + return CreateArrayLiteralBoilerplate(isolate, vector, elems); } + Handle<BoilerplateDescription> props = + Handle<BoilerplateDescription>::cast(elements); + bool use_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; + bool has_null_prototype = (flags & ObjectLiteral::kHasNullPrototype) != 0; + return CreateObjectLiteralBoilerplate(isolate, vector, props, + use_fast_elements, has_null_prototype); } @@ -233,8 +216,9 @@ RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { 2); CONVERT_SMI_ARG_CHECKED(flags, 3); Handle<FeedbackVector> vector(closure->feedback_vector(), isolate); - bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; + bool use_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; bool enable_mementos = (flags & ObjectLiteral::kDisableMementos) == 0; + bool has_null_prototype = (flags & ObjectLiteral::kHasNullPrototype) != 0; FeedbackSlot literals_slot(FeedbackVector::ToSlot(literals_index)); CHECK(literals_slot.ToInt() < vector->slot_count()); @@ -248,7 +232,7 @@ RUNTIME_FUNCTION(Runtime_CreateObjectLiteral) { ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, raw_boilerplate, CreateObjectLiteralBoilerplate(isolate, vector, boilerplate_description, - should_have_fast_elements)); + use_fast_elements, has_null_prototype)); boilerplate = Handle<JSObject>::cast(raw_boilerplate); AllocationSiteCreationContext creation_context(isolate); diff --git a/deps/v8/src/runtime/runtime-object.cc b/deps/v8/src/runtime/runtime-object.cc index 4c34b0e563..eef2e6616a 100644 --- a/deps/v8/src/runtime/runtime-object.cc +++ b/deps/v8/src/runtime/runtime-object.cc @@ -126,11 +126,72 @@ static MaybeHandle<Object> KeyedGetObjectProperty(Isolate* isolate, return Runtime::GetObjectProperty(isolate, receiver_obj, key_obj); } +namespace { + +bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver, + Handle<Object> raw_key) { + DisallowHeapAllocation no_allocation; + // This implements a special case for fast property deletion: when the + // last property in an object is deleted, then instead of normalizing + // the properties, we can undo the last map transition, with a few + // prerequisites: + // (1) The receiver must be a regular object and the key a unique name. + Map* map = receiver->map(); + if (map->IsSpecialReceiverMap()) return false; + if (!raw_key->IsUniqueName()) return false; + Handle<Name> key = Handle<Name>::cast(raw_key); + // (2) The property to be deleted must be the last property. + int nof = map->NumberOfOwnDescriptors(); + if (nof == 0) return false; + int descriptor = nof - 1; + DescriptorArray* descriptors = map->instance_descriptors(); + if (descriptors->GetKey(descriptor) != *key) return false; + // (3) The property to be deleted must be deletable. + PropertyDetails details = descriptors->GetDetails(descriptor); + if (!details.IsConfigurable()) return false; + // (4) The map must have a back pointer. + Object* backpointer = map->GetBackPointer(); + if (!backpointer->IsMap()) return false; + // (5) The last transition must have been caused by adding a property + // (and not any kind of special transition). + if (Map::cast(backpointer)->NumberOfOwnDescriptors() != nof - 1) return false; + + // Preconditions successful. No more bailouts after this point. + + // Zap the property to avoid keeping objects alive. Zapping is not necessary + // for properties stored in the descriptor array. + if (details.location() == kField) { + isolate->heap()->NotifyObjectLayoutChange(*receiver, no_allocation); + Object* filler = isolate->heap()->one_pointer_filler_map(); + FieldIndex index = FieldIndex::ForPropertyIndex(map, details.field_index()); + JSObject::cast(*receiver)->RawFastPropertyAtPut(index, filler); + // We must clear any recorded slot for the deleted property, because + // subsequent object modifications might put a raw double there. + // Slot clearing is the reason why this entire function cannot currently + // be implemented in the DeleteProperty stub. + if (index.is_inobject() && !map->IsUnboxedDoubleField(index)) { + isolate->heap()->ClearRecordedSlot( + *receiver, HeapObject::RawField(*receiver, index.offset())); + } + } + // If the map was marked stable before, then there could be optimized code + // that depends on the assumption that no object that reached this map + // transitions away from it without triggering the "deoptimize dependent + // code" mechanism. + map->NotifyLeafMapLayoutChange(); + // Finally, perform the map rollback. + receiver->synchronized_set_map(Map::cast(backpointer)); + return true; +} + +} // namespace Maybe<bool> Runtime::DeleteObjectProperty(Isolate* isolate, Handle<JSReceiver> receiver, Handle<Object> key, LanguageMode language_mode) { + if (DeleteObjectPropertyFast(isolate, receiver, key)) return Just(true); + bool success = false; LookupIterator it = LookupIterator::PropertyOrElement( isolate, receiver, key, &success, LookupIterator::OWN); @@ -139,6 +200,26 @@ Maybe<bool> Runtime::DeleteObjectProperty(Isolate* isolate, return JSReceiver::DeleteProperty(&it, language_mode); } +// ES #sec-object.keys +RUNTIME_FUNCTION(Runtime_ObjectKeys) { + HandleScope scope(isolate); + Handle<Object> object = args.at(0); + + // Convert the {object} to a proper {receiver}. + Handle<JSReceiver> receiver; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, + Object::ToObject(isolate, object)); + + // Collect the own keys for the {receiver}. + Handle<FixedArray> keys; + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, keys, + KeyAccumulator::GetKeys(receiver, KeyCollectionMode::kOwnOnly, + ENUMERABLE_STRINGS, + GetKeysConversion::kConvertToString)); + return *keys; +} + // ES6 19.1.3.2 RUNTIME_FUNCTION(Runtime_ObjectHasOwnProperty) { HandleScope scope(isolate); @@ -251,18 +332,12 @@ RUNTIME_FUNCTION(Runtime_ObjectCreate) { Handle<Map> map = Map::GetObjectCreateMap(Handle<HeapObject>::cast(prototype)); - bool is_dictionary_map = map->is_dictionary_map(); - Handle<FixedArray> object_properties; - if (is_dictionary_map) { - // Allocate the actual properties dictionay up front to avoid invalid object - // state. - object_properties = - NameDictionary::New(isolate, NameDictionary::kInitialCapacity); - } // Actually allocate the object. - Handle<JSObject> object = isolate->factory()->NewJSObjectFromMap(map); - if (is_dictionary_map) { - object->set_properties(*object_properties); + Handle<JSObject> object; + if (map->is_dictionary_map()) { + object = isolate->factory()->NewSlowJSObjectFromMap(map); + } else { + object = isolate->factory()->NewJSObjectFromMap(map); } // Define the properties if properties was specified and is not undefined. @@ -459,25 +534,28 @@ Object* DeleteProperty(Isolate* isolate, Handle<Object> object, } // namespace - -RUNTIME_FUNCTION(Runtime_DeleteProperty_Sloppy) { +RUNTIME_FUNCTION(Runtime_DeleteProperty) { HandleScope scope(isolate); - DCHECK_EQ(2, args.length()); + DCHECK_EQ(3, args.length()); CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); - return DeleteProperty(isolate, object, key, SLOPPY); + CONVERT_SMI_ARG_CHECKED(language_mode, 2); + return DeleteProperty(isolate, object, key, + static_cast<LanguageMode>(language_mode)); } - -RUNTIME_FUNCTION(Runtime_DeleteProperty_Strict) { +RUNTIME_FUNCTION(Runtime_ShrinkPropertyDictionary) { HandleScope scope(isolate); DCHECK_EQ(2, args.length()); - CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); - CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); - return DeleteProperty(isolate, object, key, STRICT); + CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); + CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); + Handle<NameDictionary> dictionary(receiver->property_dictionary(), isolate); + Handle<NameDictionary> new_properties = + NameDictionary::Shrink(dictionary, key); + receiver->set_properties(*new_properties); + return Smi::kZero; } - // ES6 section 12.9.3, operator in. RUNTIME_FUNCTION(Runtime_HasProperty) { HandleScope scope(isolate); diff --git a/deps/v8/src/runtime/runtime-regexp.cc b/deps/v8/src/runtime/runtime-regexp.cc index c9f201c11d..8803deff0f 100644 --- a/deps/v8/src/runtime/runtime-regexp.cc +++ b/deps/v8/src/runtime/runtime-regexp.cc @@ -1637,10 +1637,10 @@ RUNTIME_FUNCTION(Runtime_RegExpSplit) { argv[0] = recv; argv[1] = new_flags; - Handle<JSFunction> ctor_fun = Handle<JSFunction>::cast(ctor); Handle<Object> splitter_obj; ASSIGN_RETURN_FAILURE_ON_EXCEPTION( - isolate, splitter_obj, Execution::New(ctor_fun, argc, argv.start())); + isolate, splitter_obj, + Execution::New(isolate, ctor, argc, argv.start())); splitter = Handle<JSReceiver>::cast(splitter_obj); } diff --git a/deps/v8/src/runtime/runtime-strings.cc b/deps/v8/src/runtime/runtime-strings.cc index 1ef04ed467..99fbf2d475 100644 --- a/deps/v8/src/runtime/runtime-strings.cc +++ b/deps/v8/src/runtime/runtime-strings.cc @@ -17,11 +17,12 @@ namespace internal { RUNTIME_FUNCTION(Runtime_GetSubstitution) { HandleScope scope(isolate); - DCHECK_EQ(4, args.length()); + DCHECK_EQ(5, args.length()); CONVERT_ARG_HANDLE_CHECKED(String, matched, 0); CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); CONVERT_SMI_ARG_CHECKED(position, 2); CONVERT_ARG_HANDLE_CHECKED(String, replacement, 3); + CONVERT_SMI_ARG_CHECKED(start_index, 4); // A simple match without captures. class SimpleMatch : public String::Match { @@ -58,7 +59,8 @@ RUNTIME_FUNCTION(Runtime_GetSubstitution) { SimpleMatch match(matched, prefix, suffix); RETURN_RESULT_OR_FAILURE( - isolate, String::GetSubstitution(isolate, &match, replacement)); + isolate, + String::GetSubstitution(isolate, &match, replacement, start_index)); } // This may return an empty MaybeHandle if an exception is thrown or diff --git a/deps/v8/src/runtime/runtime-test.cc b/deps/v8/src/runtime/runtime-test.cc index 4574b5103e..6e1d09f6ad 100644 --- a/deps/v8/src/runtime/runtime-test.cc +++ b/deps/v8/src/runtime/runtime-test.cc @@ -111,6 +111,21 @@ bool WasmInstantiateOverride(const v8::FunctionCallbackInfo<v8::Value>& args) { return true; } +bool GetWasmFromArray(const v8::FunctionCallbackInfo<v8::Value>& args) { + CHECK(args.Length() == 1); + v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); + v8::Local<v8::Value> module = + v8::Local<v8::Object>::Cast(args[0])->Get(context, 0).ToLocalChecked(); + + v8::Local<v8::Promise::Resolver> resolver = + v8::Promise::Resolver::New(context).ToLocalChecked(); + args.GetReturnValue().Set(resolver->GetPromise()); + USE(resolver->Resolve(context, module)); + return true; +} + +bool NoExtension(const v8::FunctionCallbackInfo<v8::Value>&) { return false; } + } // namespace namespace v8 { @@ -150,6 +165,7 @@ RUNTIME_FUNCTION(Runtime_DeoptimizeFunction) { return isolate->heap()->undefined_value(); } Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); + function->shared()->set_marked_for_tier_up(false); // If the function is not optimized, just return. if (!function->IsOptimized()) return isolate->heap()->undefined_value(); @@ -264,6 +280,11 @@ RUNTIME_FUNCTION(Runtime_OptimizeFunctionOnNextCall) { if (function->IsOptimized()) return isolate->heap()->undefined_value(); function->MarkForOptimization(); + if (FLAG_trace_opt) { + PrintF("[manually marking "); + function->ShortPrint(); + PrintF(" for optimization]\n"); + } if (args.length() == 2) { CONVERT_ARG_HANDLE_CHECKED(String, type, 1); @@ -319,7 +340,7 @@ RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { HandleScope scope(isolate); DCHECK(args.length() == 1 || args.length() == 2); int status = 0; - if (!isolate->use_crankshaft()) { + if (!isolate->use_optimizer()) { status |= static_cast<int>(OptimizationStatus::kNeverOptimize); } if (FLAG_always_opt || FLAG_prepare_always_opt) { @@ -452,6 +473,16 @@ RUNTIME_FUNCTION(Runtime_ClearFunctionFeedback) { return isolate->heap()->undefined_value(); } +RUNTIME_FUNCTION(Runtime_SetWasmCompileFromPromiseOverload) { + isolate->set_wasm_compile_callback(GetWasmFromArray); + return isolate->heap()->undefined_value(); +} + +RUNTIME_FUNCTION(Runtime_ResetWasmOverloads) { + isolate->set_wasm_compile_callback(NoExtension); + return isolate->heap()->undefined_value(); +} + RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) { // This only supports the case where the function being exported // calls an intermediate function, and the intermediate function @@ -677,16 +708,6 @@ RUNTIME_FUNCTION(Runtime_NativeScriptsCount) { return Smi::FromInt(Natives::GetBuiltinsCount()); } -// TODO(5510): remove this. -RUNTIME_FUNCTION(Runtime_GetV8Version) { - HandleScope scope(isolate); - DCHECK_EQ(0, args.length()); - - const char* version_string = v8::V8::GetVersion(); - - return *isolate->factory()->NewStringFromAsciiChecked(version_string); -} - RUNTIME_FUNCTION(Runtime_DisassembleFunction) { HandleScope scope(isolate); @@ -998,14 +1019,5 @@ RUNTIME_FUNCTION(Runtime_RedirectToWasmInterpreter) { return isolate->heap()->undefined_value(); } -RUNTIME_FUNCTION(Runtime_IncrementWaitCount) { - isolate->IncrementWaitCountForTesting(); - return isolate->heap()->undefined_value(); -} - -RUNTIME_FUNCTION(Runtime_DecrementWaitCount) { - isolate->DecrementWaitCountForTesting(); - return isolate->heap()->undefined_value(); -} } // namespace internal } // namespace v8 diff --git a/deps/v8/src/runtime/runtime-typedarray.cc b/deps/v8/src/runtime/runtime-typedarray.cc index eeaa40e5ea..aa87c921eb 100644 --- a/deps/v8/src/runtime/runtime-typedarray.cc +++ b/deps/v8/src/runtime/runtime-typedarray.cc @@ -50,6 +50,22 @@ RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) { return isolate->heap()->undefined_value(); } +RUNTIME_FUNCTION(Runtime_TypedArrayCopyElements) { + HandleScope scope(isolate); + DCHECK_EQ(3, args.length()); + CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, destination, 0); + CONVERT_ARG_HANDLE_CHECKED(JSReceiver, source, 1); + CONVERT_NUMBER_ARG_HANDLE_CHECKED(length_obj, 2); + + size_t length; + CHECK(TryNumberToSize(*length_obj, &length)); + + Handle<JSTypedArray> destination_ta = Handle<JSTypedArray>::cast(destination); + + ElementsAccessor* accessor = destination_ta->GetElementsAccessor(); + return accessor->CopyElements(source, destination, length); +} + #define BUFFER_VIEW_GETTER(Type, getter, accessor) \ RUNTIME_FUNCTION(Runtime_##Type##Get##getter) { \ HandleScope scope(isolate); \ @@ -64,6 +80,12 @@ BUFFER_VIEW_GETTER(TypedArray, Length, length) #undef BUFFER_VIEW_GETTER +RUNTIME_FUNCTION(Runtime_ArrayBufferViewWasNeutered) { + HandleScope scope(isolate); + DCHECK_EQ(1, args.length()); + return isolate->heap()->ToBoolean(JSTypedArray::cast(args[0])->WasNeutered()); +} + RUNTIME_FUNCTION(Runtime_TypedArrayGetBuffer) { HandleScope scope(isolate); DCHECK_EQ(1, args.length()); @@ -223,7 +245,6 @@ RUNTIME_FUNCTION(Runtime_IsTypedArray) { return isolate->heap()->ToBoolean(args[0]->IsJSTypedArray()); } - RUNTIME_FUNCTION(Runtime_IsSharedTypedArray) { HandleScope scope(isolate); DCHECK_EQ(1, args.length()); @@ -260,5 +281,21 @@ RUNTIME_FUNCTION(Runtime_IsSharedInteger32TypedArray) { obj->type() == kExternalInt32Array); } +RUNTIME_FUNCTION(Runtime_TypedArraySpeciesCreateByLength) { + HandleScope scope(isolate); + DCHECK(args.length() == 2); + Handle<JSTypedArray> exemplar = args.at<JSTypedArray>(0); + Handle<Object> length = args.at(1); + int argc = 1; + ScopedVector<Handle<Object>> argv(argc); + argv[0] = length; + Handle<JSTypedArray> result_array; + // TODO(tebbi): Pass correct method name. + ASSIGN_RETURN_FAILURE_ON_EXCEPTION( + isolate, result_array, + JSTypedArray::SpeciesCreate(isolate, exemplar, argc, argv.start(), "")); + return *result_array; +} + } // namespace internal } // namespace v8 diff --git a/deps/v8/src/runtime/runtime-wasm.cc b/deps/v8/src/runtime/runtime-wasm.cc index 090d5b4a40..bb5360abe9 100644 --- a/deps/v8/src/runtime/runtime-wasm.cc +++ b/deps/v8/src/runtime/runtime-wasm.cc @@ -99,9 +99,9 @@ Object* ThrowRuntimeError(Isolate* isolate, int message_id, int byte_offset, // properties). Handle<Object> detailed_stack_trace_obj = JSReceiver::GetDataProperty( error, isolate->factory()->detailed_stack_trace_symbol()); - if (detailed_stack_trace_obj->IsJSArray()) { + if (detailed_stack_trace_obj->IsFixedArray()) { Handle<FixedArray> stack_elements( - FixedArray::cast(JSArray::cast(*detailed_stack_trace_obj)->elements())); + FixedArray::cast(*detailed_stack_trace_obj)); DCHECK_GE(stack_elements->length(), 1); Handle<StackFrameInfo> top_frame( StackFrameInfo::cast(stack_elements->get(0))); diff --git a/deps/v8/src/runtime/runtime.h b/deps/v8/src/runtime/runtime.h index eb5f09db9b..386b1a8108 100644 --- a/deps/v8/src/runtime/runtime.h +++ b/deps/v8/src/runtime/runtime.h @@ -118,12 +118,19 @@ namespace internal { F(WeakCollectionHas, 3, 1) \ F(WeakCollectionDelete, 3, 1) \ F(WeakCollectionSet, 4, 1) \ - F(GetWeakSetValues, 2, 1) + F(GetWeakSetValues, 2, 1) \ + F(IsJSMap, 1, 1) \ + F(IsJSSet, 1, 1) \ + F(IsJSMapIterator, 1, 1) \ + F(IsJSSetIterator, 1, 1) \ + F(IsJSWeakMap, 1, 1) \ + F(IsJSWeakSet, 1, 1) #define FOR_EACH_INTRINSIC_COMPILER(F) \ F(CompileLazy, 1, 1) \ F(CompileOptimized_Concurrent, 1, 1) \ F(CompileOptimized_NotConcurrent, 1, 1) \ + F(EvictOptimizedCodeSlot, 1, 1) \ F(NotifyStubFailure, 0, 1) \ F(NotifyDeoptimized, 1, 1) \ F(CompileForOnStackReplacement, 1, 1) \ @@ -209,10 +216,17 @@ namespace internal { F(ForInFilter, 2, 1) \ F(ForInHasProperty, 2, 1) +#ifdef V8_TRACE_IGNITION +#define FOR_EACH_INTRINSIC_INTERPRETER_TRACE(F) \ + F(InterpreterTraceBytecodeEntry, 3, 1) \ + F(InterpreterTraceBytecodeExit, 3, 1) +#else +#define FOR_EACH_INTRINSIC_INTERPRETER_TRACE(F) +#endif + #define FOR_EACH_INTRINSIC_INTERPRETER(F) \ + FOR_EACH_INTRINSIC_INTERPRETER_TRACE(F) \ F(InterpreterNewClosure, 4, 1) \ - F(InterpreterTraceBytecodeEntry, 3, 1) \ - F(InterpreterTraceBytecodeExit, 3, 1) \ F(InterpreterAdvanceBytecodeOffset, 2, 1) #define FOR_EACH_INTRINSIC_FUNCTION(F) \ @@ -251,8 +265,8 @@ namespace internal { F(GeneratorGetSourcePosition, 1, 1) \ F(GeneratorGetResumeMode, 1, 1) -#ifdef V8_I18N_SUPPORT -#define FOR_EACH_INTRINSIC_I18N(F) \ +#ifdef V8_INTL_SUPPORT +#define FOR_EACH_INTRINSIC_INTL(F) \ F(CanonicalizeLanguageTag, 1, 1) \ F(AvailableLocalesOf, 1, 1) \ F(GetDefaultICULocale, 0, 1) \ @@ -274,63 +288,62 @@ namespace internal { F(BreakIteratorNext, 1, 1) \ F(BreakIteratorCurrent, 1, 1) \ F(BreakIteratorBreakType, 1, 1) \ - F(StringToLowerCaseI18N, 1, 1) \ - F(StringToUpperCaseI18N, 1, 1) \ + F(StringToLowerCaseIntl, 1, 1) \ + F(StringToUpperCaseIntl, 1, 1) \ F(StringLocaleConvertCase, 3, 1) \ F(DateCacheVersion, 0, 1) #else -#define FOR_EACH_INTRINSIC_I18N(F) +#define FOR_EACH_INTRINSIC_INTL(F) #endif -#define FOR_EACH_INTRINSIC_INTERNAL(F) \ - F(AllocateInNewSpace, 1, 1) \ - F(AllocateInTargetSpace, 2, 1) \ - F(AllocateSeqOneByteString, 1, 1) \ - F(AllocateSeqTwoByteString, 1, 1) \ - F(CheckIsBootstrapping, 0, 1) \ - F(CreateAsyncFromSyncIterator, 1, 1) \ - F(CreateListFromArrayLike, 1, 1) \ - F(GetAndResetRuntimeCallStats, -1 /* <= 2 */, 1) \ - F(ExportFromRuntime, 1, 1) \ - F(IncrementUseCounter, 1, 1) \ - F(InstallToContext, 1, 1) \ - F(Interrupt, 0, 1) \ - F(IS_VAR, 1, 1) \ - F(NewReferenceError, 2, 1) \ - F(NewSyntaxError, 2, 1) \ - F(NewTypeError, 2, 1) \ - F(OrdinaryHasInstance, 2, 1) \ - F(PromoteScheduledException, 0, 1) \ - F(ReThrow, 1, 1) \ - F(RunMicrotasks, 0, 1) \ - F(StackGuard, 0, 1) \ - F(Throw, 1, 1) \ - F(ThrowApplyNonFunction, 1, 1) \ - F(ThrowCannotConvertToPrimitive, 0, 1) \ - F(ThrowCalledNonCallable, 1, 1) \ - F(ThrowCalledOnNullOrUndefined, 1, 1) \ - F(ThrowConstructedNonConstructable, 1, 1) \ - F(ThrowDerivedConstructorReturnedNonObject, 0, 1) \ - F(ThrowGeneratorRunning, 0, 1) \ - F(ThrowIllegalInvocation, 0, 1) \ - F(ThrowIncompatibleMethodReceiver, 2, 1) \ - F(ThrowInvalidHint, 1, 1) \ - F(ThrowInvalidStringLength, 0, 1) \ - F(ThrowInvalidTypedArrayAlignment, 2, 1) \ - F(ThrowIteratorResultNotAnObject, 1, 1) \ - F(ThrowSymbolIteratorInvalid, 0, 1) \ - F(ThrowNonCallableInInstanceOfCheck, 0, 1) \ - F(ThrowNonObjectInInstanceOfCheck, 0, 1) \ - F(ThrowNotConstructor, 1, 1) \ - F(ThrowNotGeneric, 1, 1) \ - F(ThrowRangeError, -1 /* >= 1 */, 1) \ - F(ThrowReferenceError, 1, 1) \ - F(ThrowStackOverflow, 0, 1) \ - F(ThrowSymbolAsyncIteratorInvalid, 0, 1) \ - F(ThrowTypeError, -1 /* >= 1 */, 1) \ - F(ThrowUndefinedOrNullToObject, 1, 1) \ - F(Typeof, 1, 1) \ - F(UnwindAndFindExceptionHandler, 0, 1) \ +#define FOR_EACH_INTRINSIC_INTERNAL(F) \ + F(AllocateInNewSpace, 1, 1) \ + F(AllocateInTargetSpace, 2, 1) \ + F(AllocateSeqOneByteString, 1, 1) \ + F(AllocateSeqTwoByteString, 1, 1) \ + F(CheckIsBootstrapping, 0, 1) \ + F(CreateAsyncFromSyncIterator, 1, 1) \ + F(CreateListFromArrayLike, 1, 1) \ + F(GetAndResetRuntimeCallStats, -1 /* <= 2 */, 1) \ + F(ExportFromRuntime, 1, 1) \ + F(IncrementUseCounter, 1, 1) \ + F(InstallToContext, 1, 1) \ + F(Interrupt, 0, 1) \ + F(IS_VAR, 1, 1) \ + F(NewReferenceError, 2, 1) \ + F(NewSyntaxError, 2, 1) \ + F(NewTypeError, 2, 1) \ + F(OrdinaryHasInstance, 2, 1) \ + F(PromoteScheduledException, 0, 1) \ + F(ReThrow, 1, 1) \ + F(RunMicrotasks, 0, 1) \ + F(StackGuard, 0, 1) \ + F(Throw, 1, 1) \ + F(ThrowApplyNonFunction, 1, 1) \ + F(ThrowCannotConvertToPrimitive, 0, 1) \ + F(ThrowCalledNonCallable, 1, 1) \ + F(ThrowCalledOnNullOrUndefined, 1, 1) \ + F(ThrowConstructedNonConstructable, 1, 1) \ + F(ThrowConstructorReturnedNonObject, 0, 1) \ + F(ThrowGeneratorRunning, 0, 1) \ + F(ThrowIllegalInvocation, 0, 1) \ + F(ThrowIncompatibleMethodReceiver, 2, 1) \ + F(ThrowInvalidHint, 1, 1) \ + F(ThrowInvalidStringLength, 0, 1) \ + F(ThrowInvalidTypedArrayAlignment, 2, 1) \ + F(ThrowIteratorResultNotAnObject, 1, 1) \ + F(ThrowSymbolIteratorInvalid, 0, 1) \ + F(ThrowNonCallableInInstanceOfCheck, 0, 1) \ + F(ThrowNonObjectInInstanceOfCheck, 0, 1) \ + F(ThrowNotConstructor, 1, 1) \ + F(ThrowRangeError, -1 /* >= 1 */, 1) \ + F(ThrowReferenceError, 1, 1) \ + F(ThrowStackOverflow, 0, 1) \ + F(ThrowSymbolAsyncIteratorInvalid, 0, 1) \ + F(ThrowTypeError, -1 /* >= 1 */, 1) \ + F(ThrowUndefinedOrNullToObject, 1, 1) \ + F(Typeof, 1, 1) \ + F(UnwindAndFindExceptionHandler, 0, 1) \ F(AllowDynamicFunction, 1, 1) #define FOR_EACH_INTRINSIC_LITERALS(F) \ @@ -378,6 +391,7 @@ namespace internal { #define FOR_EACH_INTRINSIC_OBJECT(F) \ F(AddDictionaryProperty, 3, 1) \ F(GetPrototype, 1, 1) \ + F(ObjectKeys, 1, 1) \ F(ObjectHasOwnProperty, 2, 1) \ F(ObjectCreate, 2, 1) \ F(InternalSetPrototype, 2, 1) \ @@ -388,8 +402,8 @@ namespace internal { F(SetProperty, 4, 1) \ F(AddElement, 3, 1) \ F(AppendElement, 2, 1) \ - F(DeleteProperty_Sloppy, 2, 1) \ - F(DeleteProperty_Strict, 2, 1) \ + F(DeleteProperty, 3, 1) \ + F(ShrinkPropertyDictionary, 2, 1) \ F(HasProperty, 2, 1) \ F(GetOwnPropertyKeys, 2, 1) \ F(GetInterceptorInfo, 1, 1) \ @@ -466,9 +480,7 @@ namespace internal { F(PromiseRevokeReject, 1, 1) \ F(PromiseResult, 1, 1) \ F(PromiseStatus, 1, 1) \ - F(ReportPromiseReject, 2, 1) \ - F(IncrementWaitCount, 0, 1) \ - F(DecrementWaitCount, 0, 1) + F(ReportPromiseReject, 2, 1) #define FOR_EACH_INTRINSIC_PROXY(F) \ F(IsJSProxy, 1, 1) \ @@ -519,7 +531,7 @@ namespace internal { F(StoreLookupSlot_Strict, 2, 1) #define FOR_EACH_INTRINSIC_STRINGS(F) \ - F(GetSubstitution, 4, 1) \ + F(GetSubstitution, 5, 1) \ F(StringReplaceOneCharWithString, 3, 1) \ F(StringIndexOf, 3, 1) \ F(StringIndexOfUnchecked, 3, 1) \ @@ -581,7 +593,6 @@ namespace internal { F(Abort, 1, 1) \ F(AbortJS, 1, 1) \ F(NativeScriptsCount, 0, 1) \ - F(GetV8Version, 0, 1) \ F(DisassembleFunction, 1, 1) \ F(TraceEnter, 0, 1) \ F(TraceExit, 1, 1) \ @@ -617,24 +628,29 @@ namespace internal { F(ValidateWasmOrphanedInstance, 1, 1) \ F(SetWasmCompileControls, 2, 1) \ F(SetWasmInstantiateControls, 0, 1) \ + F(SetWasmCompileFromPromiseOverload, 0, 1) \ + F(ResetWasmOverloads, 0, 1) \ F(HeapObjectVerify, 1, 1) \ F(WasmNumInterpretedCalls, 1, 1) \ F(RedirectToWasmInterpreter, 2, 1) -#define FOR_EACH_INTRINSIC_TYPEDARRAY(F) \ - F(ArrayBufferGetByteLength, 1, 1) \ - F(ArrayBufferNeuter, 1, 1) \ - F(ArrayBufferViewGetByteLength, 1, 1) \ - F(ArrayBufferViewGetByteOffset, 1, 1) \ - F(TypedArrayGetLength, 1, 1) \ - F(TypedArrayGetBuffer, 1, 1) \ - F(TypedArraySetFastCases, 3, 1) \ - F(TypedArraySortFast, 1, 1) \ - F(TypedArrayMaxSizeInHeap, 0, 1) \ - F(IsTypedArray, 1, 1) \ - F(IsSharedTypedArray, 1, 1) \ - F(IsSharedIntegerTypedArray, 1, 1) \ - F(IsSharedInteger32TypedArray, 1, 1) +#define FOR_EACH_INTRINSIC_TYPEDARRAY(F) \ + F(ArrayBufferGetByteLength, 1, 1) \ + F(ArrayBufferNeuter, 1, 1) \ + F(TypedArrayCopyElements, 3, 1) \ + F(ArrayBufferViewGetByteLength, 1, 1) \ + F(ArrayBufferViewGetByteOffset, 1, 1) \ + F(ArrayBufferViewWasNeutered, 1, 1) \ + F(TypedArrayGetLength, 1, 1) \ + F(TypedArrayGetBuffer, 1, 1) \ + F(TypedArraySetFastCases, 3, 1) \ + F(TypedArraySortFast, 1, 1) \ + F(TypedArrayMaxSizeInHeap, 0, 1) \ + F(IsTypedArray, 1, 1) \ + F(IsSharedTypedArray, 1, 1) \ + F(IsSharedIntegerTypedArray, 1, 1) \ + F(IsSharedInteger32TypedArray, 1, 1) \ + F(TypedArraySpeciesCreateByLength, 2, 1) #define FOR_EACH_INTRINSIC_WASM(F) \ F(WasmGrowMemory, 1, 1) \ @@ -692,7 +708,7 @@ namespace internal { FOR_EACH_INTRINSIC_INTERPRETER(F) \ FOR_EACH_INTRINSIC_FUNCTION(F) \ FOR_EACH_INTRINSIC_GENERATOR(F) \ - FOR_EACH_INTRINSIC_I18N(F) \ + FOR_EACH_INTRINSIC_INTL(F) \ FOR_EACH_INTRINSIC_INTERNAL(F) \ FOR_EACH_INTRINSIC_LITERALS(F) \ FOR_EACH_INTRINSIC_LIVEEDIT(F) \ |