!7928 ArraySort NativeInlineLowering

Merge pull request !7928 from YuliCheng/ArraySortNativeInlineLowering
This commit is contained in:
openharmony_ci 2024-07-19 14:16:31 +00:00 committed by Gitee
commit c1109fc0c1
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
17 changed files with 191 additions and 52 deletions

View File

@ -1382,6 +1382,13 @@ void BuiltinsArrayStubBuilder::Slice(GateRef glue, GateRef thisValue, GateRef nu
void BuiltinsArrayStubBuilder::Sort(GateRef glue, GateRef thisValue,
GateRef numArgs, Variable *result, Label *exit, Label *slowPath)
{
GateRef callbackFnHandle = GetCallArg0(numArgs);
SortAfterArgs(glue, thisValue, callbackFnHandle, result, exit, slowPath);
}
void BuiltinsArrayStubBuilder::SortAfterArgs(GateRef glue, GateRef thisValue,
GateRef callbackFnHandle, Variable *result, Label *exit, Label *slowPath, GateRef hir)
{
auto env = GetEnvironment();
Label isHeapObject(env);
@ -1400,11 +1407,9 @@ void BuiltinsArrayStubBuilder::Sort(GateRef glue, GateRef thisValue,
Bind(&isStability);
BRANCH(IsJsCOWArray(thisValue), slowPath, &notCOWArray);
Bind(&notCOWArray);
GateRef callbackFnHandle = GetCallArg0(numArgs);
BRANCH(TaggedIsUndefined(callbackFnHandle), &argUndefined, slowPath);
Bind(&argUndefined);
result->WriteVariable(DoSort(glue, thisValue, Boolean(false), result, exit, slowPath));
result->WriteVariable(DoSort(glue, thisValue, Boolean(false), result, exit, slowPath, hir));
Jump(exit);
}
@ -1460,7 +1465,7 @@ void BuiltinsArrayStubBuilder::ToSorted(GateRef glue, GateRef thisValue,
}
GateRef BuiltinsArrayStubBuilder::DoSort(GateRef glue, GateRef receiver, GateRef receiverState,
Variable *result, Label *exit, Label *slowPath)
Variable *result, Label *exit, Label *slowPath, GateRef hir)
{
auto env = GetEnvironment();
Label entry(env);
@ -1493,7 +1498,7 @@ GateRef BuiltinsArrayStubBuilder::DoSort(GateRef glue, GateRef receiver, GateRef
BRANCH(TaggedIsTrue(presentValueHasProp), &presentValueHasProperty, &afterGettingpresentValue);
Bind(&presentValueHasProperty);
{
presentValue = FastGetPropertyByIndex(glue, receiver, TruncInt64ToInt32(*i), ProfileOperation());
presentValue = FastGetPropertyByIndex(glue, receiver, TruncInt64ToInt32(*i), ProfileOperation(), hir);
BRANCH(HasPendingException(glue), &presentValueHasException0, &afterGettingpresentValue);
Bind(&presentValueHasException0);
{
@ -1529,7 +1534,7 @@ GateRef BuiltinsArrayStubBuilder::DoSort(GateRef glue, GateRef receiver, GateRef
Bind(&middleValueHasProperty);
{
middleValue = FastGetPropertyByIndex(glue, receiver,
TruncInt64ToInt32(middleIndex), ProfileOperation());
TruncInt64ToInt32(middleIndex), ProfileOperation(), hir);
BRANCH(HasPendingException(glue), &middleValueHasException0, &afterGettingmiddleValue);
Bind(&middleValueHasException0);
{
@ -1602,7 +1607,7 @@ GateRef BuiltinsArrayStubBuilder::DoSort(GateRef glue, GateRef receiver, GateRef
Bind(&previousValueHasProperty);
{
previousValue = FastGetPropertyByIndex(glue, receiver,
TruncInt64ToInt32(Int64Sub(*j, Int64(1))), ProfileOperation());
TruncInt64ToInt32(Int64Sub(*j, Int64(1))), ProfileOperation(), hir);
BRANCH(HasPendingException(glue), &previousValueHasException0, &afterGettingpreviousValue);
Bind(&previousValueHasException0);
{

View File

@ -38,6 +38,9 @@ BUILTINS_WITH_ARRAY_STUB_BUILDER(DECLARE_BUILTINS_ARRAY_STUB_BUILDER)
void Sort(GateRef glue, GateRef thisValue, GateRef numArgs, Variable *result, Label *exit, Label *slowPath);
void SortAfterArgs(GateRef glue, GateRef thisValue, GateRef callbackFnHandle,
Variable *result, Label *exit, Label *slowPath, GateRef hir = Circuit::NullGate());
void GenArrayConstructor(GateRef glue, GateRef nativeCode, GateRef func,
GateRef newTarget, GateRef thisValue, GateRef numArgs);
@ -51,7 +54,7 @@ BUILTINS_WITH_ARRAY_STUB_BUILDER(DECLARE_BUILTINS_ARRAY_STUB_BUILDER)
Variable *result, Label *exit);
GateRef DoSort(GateRef glue, GateRef receiver, GateRef receiverState,
Variable *result, Label *exit, Label *slowPath);
Variable *result, Label *exit, Label *slowPath, GateRef hir = Circuit::NullGate());
void FastReverse(GateRef glue, GateRef thisValue, GateRef len,
ElementsKind kind, Variable *result, Label *exit);

View File

@ -376,6 +376,7 @@ public:
}
// NOTE(schernykh): try to remove this switch and move StringFromCharCode to TYPED_BUILTINS_INLINE list
switch (builtinId) {
case BuiltinsStubCSigns::ID::ArraySort:
case BuiltinsStubCSigns::ID::StringFromCharCode:
case BuiltinsStubCSigns::ID::StringSubstring:
case BuiltinsStubCSigns::ID::StringSubStr:

View File

@ -163,7 +163,7 @@ void CallStubBuilder::JSCallNative(Label *exit)
case JSCallMode::CALL_THIS_ARG2_WITH_RETURN:
case JSCallMode::CALL_THIS_ARG3_WITH_RETURN:
case JSCallMode::CALL_THIS_ARGV_WITH_RETURN:
ret = CallNGCRuntime(glue_, idxForNative, argsForNative);
ret = CallNGCRuntime(glue_, idxForNative, argsForNative, hir_);
break;
case JSCallMode::SUPER_CALL_WITH_ARGV:
case JSCallMode::SUPER_CALL_SPREAD_WITH_ARGV:
@ -331,11 +331,11 @@ void CallStubBuilder::CallBridge(GateRef code, GateRef expectedNum, Label *exit)
case JSCallMode::CALL_THIS_ARG2_WITH_RETURN:
case JSCallMode::CALL_THIS_ARG3_WITH_RETURN:
if (IsFastAotCall()) {
ret = FastCallOptimized(glue_, code, argsForAot);
ret = FastCallOptimized(glue_, code, argsForAot, hir_);
} else if (IsSlowAotCall()) {
ret = CallOptimized(glue_, code, argsForAot);
ret = CallOptimized(glue_, code, argsForAot, hir_);
} else {
ret = CallNGCRuntime(glue_, idxForAot, argsForAot);
ret = CallNGCRuntime(glue_, idxForAot, argsForAot, hir_);
}
break;
case JSCallMode::CALL_WITH_ARGV:
@ -415,7 +415,7 @@ void CallStubBuilder::JSCallAsmInterpreter(bool hasBaselineCode, Label *methodNo
} else if (hasBaselineCode) {
Jump(methodNotAot);
} else {
*result_ = CallNGCRuntime(glue_, idxForAsmInterpreter, argsForAsmInterpreter);
*result_ = CallNGCRuntime(glue_, idxForAsmInterpreter, argsForAsmInterpreter, hir_);
Jump(exit);
}
break;

View File

@ -111,7 +111,8 @@ class CallStubBuilder : public StubBuilder {
public:
explicit CallStubBuilder(StubBuilder *parent, GateRef glue, GateRef func, GateRef actualNumArgs, GateRef jumpSize,
Variable *result, GateRef hotnessCounter, JSCallArgs callArgs,
ProfileOperation callback = ProfileOperation(), bool checkIsCallable = true)
ProfileOperation callback = ProfileOperation(),
bool checkIsCallable = true, GateRef hir = Circuit::NullGate())
: StubBuilder(parent)
{
this->glue_ = glue;
@ -123,6 +124,7 @@ public:
this->callArgs_ = callArgs;
this->callback_ = callback;
this->checkIsCallable_ = checkIsCallable;
this->hir_ = hir;
}
explicit CallStubBuilder(Environment *env)
: StubBuilder(env) {}
@ -146,6 +148,7 @@ private:
JSCallArgs callArgs_;
ProfileOperation callback_;
bool checkIsCallable_ {true};
GateRef hir_ {0};
bool isFast_ {true};
bool isBridge_ {false};

View File

@ -787,6 +787,7 @@ public:
GateRef thisArray, GateRef fromIndex, GateRef targetElement, GateRef CallID, GateRef ArrayKind);
GateRef ArrayIteratorBuiltin(GateRef thisArray, GateRef callID);
GateRef ArrayForEach(GateRef thisValue, GateRef callBackFn, GateRef usingThis, uint32_t pcOffset);
GateRef ArraySort(GateRef thisValue, GateRef callBackFn);
GateRef ArrayFilter(
GateRef thisValue, GateRef callBackFn, GateRef usingThis, GateRef frameState, uint32_t pcOffset);
GateRef ArrayMap(GateRef thisValue, GateRef callBackFn, GateRef usingThis, GateRef frameState, uint32_t pcOffset);

View File

@ -1841,6 +1841,20 @@ GateRef CircuitBuilder::ArrayForEach(GateRef thisValue, GateRef callBackFn, Gate
return ret;
}
GateRef CircuitBuilder::ArraySort(GateRef thisValue, GateRef callBackFn)
{
auto currentLabel = env_->GetCurrentLabel();
auto currentControl = currentLabel->GetControl();
auto currentDepend = currentLabel->GetDepend();
GateRef ret = GetCircuit()->NewGate(circuit_->ArraySort(),
MachineType::I64,
{currentControl, currentDepend, thisValue, callBackFn},
GateType::AnyType());
currentLabel->SetControl(ret);
currentLabel->SetDepend(ret);
return ret;
}
GateRef CircuitBuilder::ArrayFilter(
GateRef thisValue, GateRef callBackFn, GateRef usingThis, GateRef frameState, uint32_t pcOffset)
{

View File

@ -163,6 +163,7 @@ namespace panda::ecmascript::kungfu {
V(ArrayIteratorBuiltin, ARRAY_ITERATOR_BUILTIN, GateFlags::NONE_FLAG, 1, 1, 2) \
V(ArrayPop, ARRAY_POP, GateFlags::NONE_FLAG, 1, 1, 2) \
V(ArraySlice, ARRAY_SLICE, GateFlags::NONE_FLAG, 1, 1, 4) \
V(ArraySort, ARRAY_SORT, GateFlags::NONE_FLAG, 1, 1, 2) \
MCR_BINARY_GATE_META_DATA_CACHE_LIST(V)
#define MCR_GATE_META_DATA_LIST_WITH_PC_OFFSET(V) \

View File

@ -311,6 +311,9 @@ void NativeInlineLowering::RunNativeInlineLowering()
case BuiltinsStubCSigns::ID::SetClear:
InlineStubBuiltin(gate, 0U, argc, id, circuit_->SetClear(), skipThis);
break;
case BuiltinsStubCSigns::ID::ArraySort:
TryInlineArraySort(gate, argc, id, skipThis);
break;
case BuiltinsStubCSigns::ID::ObjectIs:
TryInlineObjectIs(gate, argc, id, skipThis);
break;
@ -1778,4 +1781,37 @@ void NativeInlineLowering::TryInlineArraySlice(GateRef gate, size_t argc, Builti
}
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), ret);
}
void NativeInlineLowering::TryInlineArraySort(GateRef gate, size_t argc, BuiltinsStubCSigns::ID id, bool skipThis)
{
if (!skipThis) {
return;
}
if (argc > 1) {
return;
}
Environment env(gate, circuit_, &builder_);
if (argc == 1) {
GateRef callBackFn = acc_.GetValueIn(gate, 1);
auto fnType = acc_.GetGateType(callBackFn);
if (!fnType.IsUndefinedType()) {
return;
}
}
GateRef thisValue = acc_.GetValueIn(gate, 0);
ElementsKind kind = acc_.TryGetArrayElementsKind(thisValue);
if (Elements::IsHole(kind)) {
return;
}
if (!Uncheck()) {
builder_.CallTargetCheck(gate, acc_.GetValueIn(gate, argc + 1), builder_.IntPtr(static_cast<int64_t>(id)));
}
GateRef ret = Circuit::NullGate();
builder_.BuiltinPrototypeHClassCheck(thisValue, BuiltinTypeId::ARRAY, kind, false);
builder_.StableArrayCheck(thisValue, kind, ArrayMetaDataAccessor::Mode::LOAD_ELEMENT);
ret = builder_.ArraySort(thisValue, builder_.UndefineConstant());
acc_.ReplaceHirAndDeleteIfException(gate, builder_.GetStateDepend(), ret);
}
} // namespace panda::ecmascript

View File

@ -110,6 +110,7 @@ private:
void TryInlineArrayEvery(GateRef gate, size_t argc, BuiltinsStubCSigns::ID id, bool skipThis);
void TryInlineArrayPop(GateRef gate, size_t argc, BuiltinsStubCSigns::ID id, bool skipThis);
void TryInlineArraySlice(GateRef gate, size_t argc, BuiltinsStubCSigns::ID id, bool skipThis);
void TryInlineArraySort(GateRef gate, size_t argc, BuiltinsStubCSigns::ID id, bool skipThis);
bool EnableLog() const
{

View File

@ -230,23 +230,40 @@ inline GateRef StubBuilder::CallRuntime(GateRef glue, int index, GateRef argc, G
return result;
}
inline GateRef StubBuilder::CallNGCRuntime(GateRef glue, int index, const std::vector<GateRef>& args)
inline GateRef StubBuilder::CallNGCRuntime(GateRef glue, int index,
const std::vector<GateRef>& args, GateRef hir)
{
const std::string name = RuntimeStubCSigns::GetRTName(index);
GateRef result = env_->GetBuilder()->CallNGCRuntime(glue, index, Gate::InvalidGateRef, args,
Circuit::NullGate(), name.c_str());
GateRef result;
if (env_->GetCircuit()->IsOptimizedOrFastJit()) {
result = env_->GetBuilder()->CallNGCRuntime(glue, index, Gate::InvalidGateRef, args,
hir, name.c_str());
} else {
result = env_->GetBuilder()->CallNGCRuntime(glue, index, Gate::InvalidGateRef, args,
Circuit::NullGate(), name.c_str());
}
return result;
}
inline GateRef StubBuilder::FastCallOptimized(GateRef glue, GateRef code, const std::vector<GateRef>& args)
inline GateRef StubBuilder::FastCallOptimized(GateRef glue, GateRef code, const std::vector<GateRef>& args, GateRef hir)
{
GateRef result = env_->GetBuilder()->FastCallOptimized(glue, code, Gate::InvalidGateRef, args, Circuit::NullGate());
GateRef result;
if (env_->GetCircuit()->IsOptimizedOrFastJit()) {
result = env_->GetBuilder()->FastCallOptimized(glue, code, Gate::InvalidGateRef, args, hir);
} else {
result = env_->GetBuilder()->FastCallOptimized(glue, code, Gate::InvalidGateRef, args, Circuit::NullGate());
}
return result;
}
inline GateRef StubBuilder::CallOptimized(GateRef glue, GateRef code, const std::vector<GateRef>& args)
inline GateRef StubBuilder::CallOptimized(GateRef glue, GateRef code, const std::vector<GateRef>& args, GateRef hir)
{
GateRef result = env_->GetBuilder()->CallOptimized(glue, code, Gate::InvalidGateRef, args, Circuit::NullGate());
GateRef result;
if (env_->GetCircuit()->IsOptimizedOrFastJit()) {
result = env_->GetBuilder()->CallOptimized(glue, code, Gate::InvalidGateRef, args, hir);
} else {
result = env_->GetBuilder()->CallOptimized(glue, code, Gate::InvalidGateRef, args, Circuit::NullGate());
}
return result;
}

View File

@ -1118,7 +1118,7 @@ GateRef StubBuilder::ComputeElementCapacity(GateRef oldLength)
}
GateRef StubBuilder::CallGetterHelper(
GateRef glue, GateRef receiver, GateRef holder, GateRef accessor, ProfileOperation callback)
GateRef glue, GateRef receiver, GateRef holder, GateRef accessor, ProfileOperation callback, GateRef hir)
{
auto env = GetEnvironment();
Label subEntry(env);
@ -1180,7 +1180,7 @@ GateRef StubBuilder::CallGetterHelper(
JSCallArgs callArgs(JSCallMode::CALL_GETTER);
callArgs.callGetterArgs = { receiver };
CallStubBuilder callBuilder(this, glue, getter, Int32(0), 0, &tmpResult, Circuit::NullGate(), callArgs,
callback);
callback, true, hir);
if (env->IsBaselineBuiltin()) {
callBuilder.JSCallDispatchForBaseline(&callExit);
Bind(&callExit);
@ -3087,7 +3087,8 @@ inline void StubBuilder::UpdateValueInDict(GateRef glue, GateRef elements, GateR
SetValueToTaggedArray(VariableType::JS_ANY(), glue, elements, valueIndex, value);
}
GateRef StubBuilder::GetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index, ProfileOperation callback)
GateRef StubBuilder::GetPropertyByIndex(GateRef glue, GateRef receiver,
GateRef index, ProfileOperation callback, GateRef hir)
{
auto env = GetEnvironment();
Label entry(env);
@ -3208,7 +3209,7 @@ GateRef StubBuilder::GetPropertyByIndex(GateRef glue, GateRef receiver, GateRef
BRANCH(IsAccessor(attr), &isAccessor, &notAccessor);
Bind(&isAccessor);
{
result = CallGetterHelper(glue, receiver, *holder, value, callback);
result = CallGetterHelper(glue, receiver, *holder, value, callback, hir);
Jump(&exit);
}
Bind(&notAccessor);
@ -5093,7 +5094,8 @@ GateRef StubBuilder::FastGetPropertyByName(GateRef glue, GateRef obj, GateRef ke
return ret;
}
GateRef StubBuilder::FastGetPropertyByIndex(GateRef glue, GateRef obj, GateRef index, ProfileOperation callback)
GateRef StubBuilder::FastGetPropertyByIndex(GateRef glue, GateRef obj,
GateRef index, ProfileOperation callback, GateRef hir)
{
auto env = GetEnvironment();
Label entry(env);
@ -5106,7 +5108,7 @@ GateRef StubBuilder::FastGetPropertyByIndex(GateRef glue, GateRef obj, GateRef i
BRANCH(TaggedIsHeapObject(obj), &fastPath, &slowPath);
Bind(&fastPath);
{
result = GetPropertyByIndex(glue, obj, index, callback);
result = GetPropertyByIndex(glue, obj, index, callback, hir);
Label notHole(env);
BRANCH(TaggedIsHole(*result), &slowPath, &exit);
}

View File

@ -173,9 +173,12 @@ public:
// call operation
GateRef CallRuntime(GateRef glue, int index, const std::vector<GateRef>& args);
GateRef CallRuntime(GateRef glue, int index, GateRef argc, GateRef argv);
GateRef CallNGCRuntime(GateRef glue, int index, const std::vector<GateRef>& args);
GateRef FastCallOptimized(GateRef glue, GateRef code, const std::vector<GateRef>& args);
GateRef CallOptimized(GateRef glue, GateRef code, const std::vector<GateRef>& args);
GateRef CallNGCRuntime(GateRef glue, int index,
const std::vector<GateRef>& args, GateRef hir = Circuit::NullGate());
GateRef FastCallOptimized(GateRef glue, GateRef code,
const std::vector<GateRef>& args, GateRef hir = Circuit::NullGate());
GateRef CallOptimized(GateRef glue, GateRef code,
const std::vector<GateRef>& args, GateRef hir = Circuit::NullGate());
GateRef GetAotCodeAddr(GateRef jsFunc);
GateRef CallStub(GateRef glue, int index, const std::initializer_list<GateRef>& args);
GateRef CallBuiltinRuntime(GateRef glue, const std::initializer_list<GateRef>& args, bool isNew = false);
@ -709,11 +712,13 @@ ShortcutBoolOr([&]{ return first; }, [&]{ return second; })
void SetValueWithAttr(GateRef glue, GateRef obj, GateRef offset, GateRef key, GateRef value, GateRef attr);
void SetValueWithRep(GateRef glue, GateRef obj, GateRef offset, GateRef value, GateRef rep, Label *repChange);
void SetValueWithBarrier(GateRef glue, GateRef obj, GateRef offset, GateRef value, bool withEden = false);
GateRef GetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index, ProfileOperation callback);
GateRef GetPropertyByIndex(GateRef glue, GateRef receiver, GateRef index,
ProfileOperation callback, GateRef hir = Circuit::NullGate());
GateRef GetPropertyByName(GateRef glue, GateRef receiver, GateRef key,
ProfileOperation callback, GateRef isInternal, bool canUseIsInternal = false);
GateRef FastGetPropertyByName(GateRef glue, GateRef obj, GateRef key, ProfileOperation callback);
GateRef FastGetPropertyByIndex(GateRef glue, GateRef obj, GateRef index, ProfileOperation callback);
GateRef FastGetPropertyByIndex(GateRef glue, GateRef obj, GateRef index,
ProfileOperation callback, GateRef hir = Circuit::NullGate());
GateRef GetPropertyByValue(GateRef glue, GateRef receiver, GateRef keyValue, ProfileOperation callback);
void FastSetPropertyByName(GateRef glue, GateRef obj, GateRef key, GateRef value,
ProfileOperation callback = ProfileOperation());
@ -895,8 +900,8 @@ ShortcutBoolOr([&]{ return first; }, [&]{ return second; })
inline GateRef GetSingleCharTable(GateRef glue);
inline GateRef IsEnableElementsKind(GateRef glue);
inline GateRef GetGlobalEnvValue(VariableType type, GateRef env, size_t index);
GateRef CallGetterHelper(
GateRef glue, GateRef receiver, GateRef holder, GateRef accessor, ProfileOperation callback);
GateRef CallGetterHelper(GateRef glue, GateRef receiver, GateRef holder,
GateRef accessor, ProfileOperation callback, GateRef hir = Circuit::NullGate());
GateRef ConstructorCheck(GateRef glue, GateRef ctor, GateRef outPut, GateRef thisObj);
GateRef GetCallSpreadArgs(GateRef glue, GateRef array, ProfileOperation callBack);
GateRef GetIterator(GateRef glue, GateRef obj, ProfileOperation callback);

View File

@ -18,6 +18,7 @@
#include "ecmascript/builtins/builtins_errors.h"
#include "ecmascript/byte_array.h"
#include "ecmascript/compiler/assembler/assembler.h"
#include "ecmascript/compiler/builtins/builtins_array_stub_builder.h"
#include "ecmascript/compiler/builtins/builtins_call_signature.h"
#include "ecmascript/compiler/builtins/builtins_object_stub_builder.h"
#include "ecmascript/compiler/builtins/builtins_string_stub_builder.h"
@ -360,6 +361,9 @@ GateRef TypedNativeInlineLowering::VisitGate(GateRef gate)
case OpCode::ARRAY_SLICE:
LowerArraySlice(gate);
break;
case OpCode::ARRAY_SORT:
LowerArraySort(gate);
break;
default:
break;
}
@ -3866,6 +3870,28 @@ void TypedNativeInlineLowering::CheckAndCalcuSliceIndex(GateRef length,
}
}
void TypedNativeInlineLowering::LowerArraySort(GateRef gate)
{
Environment env(gate, circuit_, &builder_);
GateRef glue = acc_.GetGlueFromArgList();
GateRef thisValue = acc_.GetValueIn(gate, 0);
GateRef callBackFn = acc_.GetValueIn(gate, 1);
BuiltinsArrayStubBuilder arrayStubBuilder(&env);
DEFVALUE(result, (&builder_), VariableType::JS_ANY(), builder_.Undefined());
Label slowPath(&env);
Label exit(&env);
arrayStubBuilder.SortAfterArgs(glue, thisValue, callBackFn, &result, &exit, &slowPath, gate);
builder_.Bind(&slowPath);
{
result.WriteVariable(builder_.CallRuntime(glue, RTSTUB_ID(ArraySort),
Gate::InvalidGateRef, { thisValue }, gate));
builder_.Jump(&exit);
}
builder_.Bind(&exit);
acc_.ReplaceGate(gate, builder_.GetStateDepend(), *result);
}
GateRef TypedNativeInlineLowering::TargetIntCompareLoop(GateRef elements,
GateRef fromIndex,
GateRef targetElement,

View File

@ -148,6 +148,7 @@ private:
void LowerFunctionPrototypeApply(GateRef gate);
void LowerFunctionPrototypeBind(GateRef gate);
void LowerFunctionPrototypeCall(GateRef gate);
void LowerArraySort(GateRef gate);
void LowerToCommonStub(GateRef gate, CommonStubCSigns::ID id);
void LowerToBuiltinStub(GateRef gate, BuiltinsStubCSigns::ID id);

View File

@ -14,26 +14,47 @@
*/
declare function print(arg:any):string;
let a = []
let l = a.push(1)
print(l)
l = a.push(1, 2, 3, 4, 5)
print(l)
{
let a = []
let l = a.push(1)
print(l)
l = a.push(1, 2, 3, 4, 5)
print(l)
for (let i = 0; i < 100; i++) {
a.push(i)
for (let i = 0; i < 100; i++) {
a.push(i)
}
let c = [1, 2, 3, 4]
a.push(...c)
print(a.length)
let b = []
b.push(1, 2, 3, 4)
b.push(1, 2, 3)
b.push(1, 2)
b.push(1)
b.push()
print(Object.values(b))
print(b.length)
}
let c = [1, 2, 3, 4]
a.push(...c)
{
let result;
let array = new Array();
let array_size = 100;
print(a.length)
for (let i = 0; i < array_size; i++) {
array[i] = i;
}
let b = []
b.push(1, 2, 3, 4)
b.push(1, 2, 3)
b.push(1, 2)
b.push(1)
b.push()
print(Object.values(b))
print(b.length)
result = array.sort((a, b) => {
return a - b
});
print(result);
result = array.sort();
print(result);
}

View File

@ -16,3 +16,5 @@
110
1,2,3,4,1,2,3,1,2,1
10
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99
0,1,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,25,26,27,28,29,3,30,31,32,33,34,35,36,37,38,39,4,40,41,42,43,44,45,46,47,48,49,5,50,51,52,53,54,55,56,57,58,59,6,60,61,62,63,64,65,66,67,68,69,7,70,71,72,73,74,75,76,77,78,79,8,80,81,82,83,84,85,86,87,88,89,9,90,91,92,93,94,95,96,97,98,99