mirror of
https://github.com/openharmony/ark_js_runtime.git
synced 2026-08-27 20:40:01 -04:00
!1276 Fix AOT slowpathlowering bugs and Add AOT test cases
Merge pull request !1276 from huoqingyi/slowlowering
This commit is contained in:
@@ -229,7 +229,6 @@ void SlowPathLowering::Lower(GateRef gate)
|
||||
GateRef glue = bcBuilder_->GetCommonArgByIndex(CommonArgIdx::GLUE);
|
||||
GateRef newTarget = bcBuilder_->GetCommonArgByIndex(CommonArgIdx::NEW_TARGET);
|
||||
GateRef jsFunc = bcBuilder_->GetCommonArgByIndex(CommonArgIdx::FUNC);
|
||||
GateRef thisObj = bcBuilder_->GetCommonArgByIndex(CommonArgIdx::THIS);
|
||||
|
||||
auto pc = bcBuilder_->GetJSBytecode(gate);
|
||||
EcmaOpcode op = static_cast<EcmaOpcode>(*pc);
|
||||
@@ -603,7 +602,7 @@ void SlowPathLowering::Lower(GateRef gate)
|
||||
LowerCreateObjectHavingMethod(gate, glue, jsFunc);
|
||||
break;
|
||||
case LDHOMEOBJECT_PREF:
|
||||
LowerLdHomeObject(gate, thisObj);
|
||||
LowerLdHomeObject(gate, jsFunc);
|
||||
break;
|
||||
case DEFINECLASSWITHBUFFER_PREF_ID16_IMM16_IMM16_V8_V8:
|
||||
LowerDefineClassWithBuffer(gate, glue, jsFunc);
|
||||
@@ -2523,13 +2522,18 @@ void SlowPathLowering::LowerCreateObjectHavingMethod(GateRef gate, GateRef glue,
|
||||
GateRef literal = GetObjectFromConstPool(jsFunc, imm);
|
||||
GateRef env = acc_.GetValueIn(gate, 1);
|
||||
GateRef constpool = GetConstPool(jsFunc);
|
||||
GateRef newGate = LowerCallRuntime(glue, id, { literal, env, constpool });
|
||||
ReplaceHirToCall(gate, newGate);
|
||||
GateRef result = LowerCallRuntime(glue, id, { literal, env, constpool });
|
||||
Label successExit(&builder_);
|
||||
Label exceptionExit(&builder_);
|
||||
builder_.Branch(builder_.IsSpecial(result, JSTaggedValue::VALUE_EXCEPTION),
|
||||
&exceptionExit, &successExit);
|
||||
CREATE_DOUBLE_EXIT(successExit, exceptionExit)
|
||||
ReplaceHirToSubCfg(gate, result, successControl, failControl);
|
||||
}
|
||||
|
||||
void SlowPathLowering::LowerLdHomeObject(GateRef gate, GateRef thisFunc)
|
||||
void SlowPathLowering::LowerLdHomeObject(GateRef gate, GateRef jsFunc)
|
||||
{
|
||||
GateRef homeObj = GetHomeObjectFromJSFunction(thisFunc);
|
||||
GateRef homeObj = GetHomeObjectFromJSFunction(jsFunc);
|
||||
std::vector<GateRef> successControl;
|
||||
std::vector<GateRef> exceptionControl;
|
||||
successControl.emplace_back(builder_.GetState());
|
||||
|
||||
@@ -252,7 +252,7 @@ private:
|
||||
void LowerLdLexVarDyn(GateRef gate, GateRef jsFunc);
|
||||
void LowerStLexVarDyn(GateRef gate, GateRef glue, GateRef jsFunc);
|
||||
void LowerCreateObjectHavingMethod(GateRef gate, GateRef glue, GateRef jsFunc);
|
||||
void LowerLdHomeObject(GateRef gate, GateRef thisFunc);
|
||||
void LowerLdHomeObject(GateRef gate, GateRef jsFunc);
|
||||
void LowerDefineClassWithBuffer(GateRef gate, GateRef glue, GateRef jsFunc);
|
||||
void LowerAsyncFunctionEnter(GateRef gate, GateRef glue);
|
||||
void LowerTypeOfDyn(GateRef gate, GateRef glue);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//ark/js_runtime/test/test_helper.gni")
|
||||
|
||||
host_aot_test_action("createobjecthavingmethod") {
|
||||
deps = []
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
declare function print(arg:any):string;
|
||||
var obj = {
|
||||
value: 1,
|
||||
fun (a:number) {print(this.value + a)},
|
||||
};
|
||||
|
||||
obj.fun(1);
|
||||
@@ -0,0 +1,14 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
2
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//ark/js_runtime/test/test_helper.gni")
|
||||
|
||||
host_aot_test_action("defineclasswithbuffer") {
|
||||
deps = []
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
declare function print(str:any):string;
|
||||
class Obj1 {
|
||||
value:number;
|
||||
constructor(value:number) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
class Obj2 {
|
||||
fun():void {
|
||||
print("Hello World");
|
||||
}
|
||||
}
|
||||
|
||||
var obj1 = new Obj1(0);
|
||||
print(obj1.value);
|
||||
var obj2 = new Obj2();
|
||||
obj2.fun();
|
||||
@@ -0,0 +1,15 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
0
|
||||
Hello World
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//ark/js_runtime/test/test_helper.gni")
|
||||
|
||||
host_aot_test_action("getiteratornext") {
|
||||
deps = []
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
0
|
||||
1
|
||||
1
|
||||
0
|
||||
0
|
||||
1,2
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
declare function print(str:any):string;
|
||||
var [a, b] = [0, 1];
|
||||
print(a);
|
||||
print(b);
|
||||
[a, b] = [b, a];
|
||||
print(a);
|
||||
print(b);
|
||||
|
||||
var [c, ...rest] = [0, 1, 2];
|
||||
print(c);
|
||||
print(rest);
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//ark/js_runtime/test/test_helper.gni")
|
||||
|
||||
host_aot_test_action("isfalse") {
|
||||
deps = []
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
declare function print(tmp:any):string;
|
||||
var num1:number = 123;
|
||||
var num2:number = 0;
|
||||
var num3:number = -0;
|
||||
var num4:number = 123.456;
|
||||
var num5:number = NaN;
|
||||
var str:string = "abc";
|
||||
var empString:string = "";
|
||||
var undefinedValue:undefined = undefined;
|
||||
var nullValue:null = null;
|
||||
var arr : Array<any> = [1, "a"];
|
||||
var obj : {[key:string]:any} = {name: "a"};
|
||||
|
||||
print(true || true);
|
||||
print(true || false);
|
||||
print(false || true);
|
||||
print(false || false);
|
||||
print(num1 || 1);
|
||||
print(num2 || 1);
|
||||
print(num3 || 1);
|
||||
print(num4 || 1);
|
||||
print(num5 || 1);
|
||||
print(str || 1);
|
||||
print(empString || 1);
|
||||
print(undefinedValue || 1);
|
||||
print(nullValue || 1);
|
||||
print(arr || 1);
|
||||
print(obj || 1);
|
||||
@@ -0,0 +1,28 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
true
|
||||
true
|
||||
true
|
||||
false
|
||||
123
|
||||
1
|
||||
1
|
||||
123.456
|
||||
1
|
||||
abc
|
||||
1
|
||||
1
|
||||
1
|
||||
1,a
|
||||
[object Object]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//ark/js_runtime/test/test_helper.gni")
|
||||
|
||||
host_aot_test_action("istrue") {
|
||||
deps = []
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
declare function print(tmp:any):string;
|
||||
var num1:number = 123;
|
||||
var num2:number = 0;
|
||||
var num3:number = -0;
|
||||
var num4:number = 123.456;
|
||||
var num5:number = NaN;
|
||||
var str:string = "abc";
|
||||
var empString:string = "";
|
||||
var undefinedValue:undefined = undefined;
|
||||
var nullValue:null = null;
|
||||
var arr : Array<any> = [1, "a"];
|
||||
var obj : {[key:string]:any} = {name: "a"};
|
||||
|
||||
print(true && true);
|
||||
print(true && false);
|
||||
print(false && true);
|
||||
print(false && false);
|
||||
print(num1 && 1);
|
||||
print(num2 && 1);
|
||||
print(num3 && 1);
|
||||
print(num4 && 1);
|
||||
print(num5 && 1);
|
||||
print(str && 1);
|
||||
print(empString && 1);
|
||||
print(undefinedValue && 1);
|
||||
print(nullValue && 1);
|
||||
print(arr && 1);
|
||||
print(obj && 1);
|
||||
@@ -0,0 +1,28 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
1
|
||||
0
|
||||
0
|
||||
1
|
||||
NaN
|
||||
1
|
||||
|
||||
undefined
|
||||
null
|
||||
1
|
||||
1
|
||||
Reference in New Issue
Block a user