Skip to content

Commit dcf34b4

Browse files
committed
Add backed intrinsics to private functions exposed with private symbols in global object
https://bugs.webkit.org/show_bug.cgi?id=144545 Reviewed by Darin Adler. Math.abs and Math.floor have ASM intrinsics And it is further accelerated in DFG/FTL layers. This patch adds intrinsic to private functions exposed with private symbols in global object, @floor and @abs. * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalPrivateFuncAbs): Deleted. (JSC::globalPrivateFuncFloor): Deleted. * runtime/MathObject.cpp: * runtime/MathObject.h: * tests/stress/array-from-abs-and-floor.js: Added. (target1): (target2): (target3): Canonical link: https://commits.webkit.org/162620@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183785 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 5c0e8e9 commit dcf34b4

6 files changed

Lines changed: 70 additions & 14 deletions

File tree

Source/JavaScriptCore/ChangeLog

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
2015-05-03 Yusuke Suzuki <utatane.tea@gmail.com>
2+
3+
Add backed intrinsics to private functions exposed with private symbols in global object
4+
https://bugs.webkit.org/show_bug.cgi?id=144545
5+
6+
Reviewed by Darin Adler.
7+
8+
Math.abs and Math.floor have ASM intrinsics And it is further accelerated in DFG/FTL layers.
9+
This patch adds intrinsic to private functions exposed with private symbols in global object,
10+
@floor and @abs.
11+
12+
* runtime/JSGlobalObject.cpp:
13+
(JSC::JSGlobalObject::init):
14+
* runtime/JSGlobalObjectFunctions.cpp:
15+
(JSC::globalPrivateFuncAbs): Deleted.
16+
(JSC::globalPrivateFuncFloor): Deleted.
17+
* runtime/MathObject.cpp:
18+
* runtime/MathObject.h:
19+
* tests/stress/array-from-abs-and-floor.js: Added.
20+
(target1):
21+
(target2):
22+
(target3):
23+
124
2015-05-04 Csaba Osztrogonác <ossy@webkit.org>
225

326
[cmake] ARM related build system cleanup

Source/JavaScriptCore/runtime/JSGlobalObject.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct
426426

427427
JSFunction* builtinLog = JSFunction::create(vm, this, 1, vm.propertyNames->emptyIdentifier.string(), globalFuncBuiltinLog);
428428

429-
JSFunction* privateFuncAbs = JSFunction::create(vm, this, 0, String(), globalPrivateFuncAbs);
430-
JSFunction* privateFuncFloor = JSFunction::create(vm, this, 0, String(), globalPrivateFuncFloor);
429+
JSFunction* privateFuncAbs = JSFunction::create(vm, this, 0, String(), mathProtoFuncAbs, AbsIntrinsic);
430+
JSFunction* privateFuncFloor = JSFunction::create(vm, this, 0, String(), mathProtoFuncFloor, FloorIntrinsic);
431431
JSFunction* privateFuncIsFinite = JSFunction::create(vm, this, 0, String(), globalFuncIsFinite);
432432

433433
JSFunction* privateFuncObjectKeys = JSFunction::create(vm, this, 0, String(), objectConstructorKeys);

Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -759,16 +759,6 @@ EncodedJSValue JSC_HOST_CALL globalFuncThrowTypeError(ExecState* exec)
759759
return throwVMTypeError(exec);
760760
}
761761

762-
EncodedJSValue JSC_HOST_CALL globalPrivateFuncAbs(ExecState* exec)
763-
{
764-
return JSValue::encode(jsNumber(fabs(exec->argument(0).toNumber(exec))));
765-
}
766-
767-
EncodedJSValue JSC_HOST_CALL globalPrivateFuncFloor(ExecState* exec)
768-
{
769-
return JSValue::encode(jsNumber(floor(exec->argument(0).toNumber(exec))));
770-
}
771-
772762
class GlobalFuncProtoGetterFunctor {
773763
public:
774764
GlobalFuncProtoGetterFunctor(JSObject* thisObject)

Source/JavaScriptCore/runtime/MathObject.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ namespace JSC {
3636

3737
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(MathObject);
3838

39-
EncodedJSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState*);
4039
EncodedJSValue JSC_HOST_CALL mathProtoFuncACos(ExecState*);
4140
EncodedJSValue JSC_HOST_CALL mathProtoFuncACosh(ExecState*);
4241
EncodedJSValue JSC_HOST_CALL mathProtoFuncASin(ExecState*);
@@ -51,7 +50,6 @@ EncodedJSValue JSC_HOST_CALL mathProtoFuncCos(ExecState*);
5150
EncodedJSValue JSC_HOST_CALL mathProtoFuncCosh(ExecState*);
5251
EncodedJSValue JSC_HOST_CALL mathProtoFuncExp(ExecState*);
5352
EncodedJSValue JSC_HOST_CALL mathProtoFuncExpm1(ExecState*);
54-
EncodedJSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState*);
5553
EncodedJSValue JSC_HOST_CALL mathProtoFuncFround(ExecState*);
5654
EncodedJSValue JSC_HOST_CALL mathProtoFuncHypot(ExecState*);
5755
EncodedJSValue JSC_HOST_CALL mathProtoFuncLog(ExecState*);

Source/JavaScriptCore/runtime/MathObject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class MathObject : public JSNonFinalObject {
5151
void finishCreation(VM&, JSGlobalObject*);
5252
};
5353

54+
EncodedJSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState*);
55+
EncodedJSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState*);
56+
5457
} // namespace JSC
5558

5659
#endif // MathObject_h
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
function target1() {
2+
return Array.from({
3+
length: 5,
4+
0: 0,
5+
1: 0,
6+
2: 0,
7+
3: 0,
8+
4: 0
9+
});
10+
}
11+
noInline(target1);
12+
13+
function target2() {
14+
return Array.from({
15+
length: 5.4,
16+
0: 0,
17+
1: 0,
18+
2: 0,
19+
3: 0,
20+
4: 0
21+
});
22+
}
23+
noInline(target2);
24+
25+
function target3() {
26+
return Array.from({
27+
length: -5.4,
28+
0: 0,
29+
1: 0,
30+
2: 0,
31+
3: 0,
32+
4: 0
33+
});
34+
}
35+
noInline(target3);
36+
37+
for (var i = 0; i < 10000; ++i)
38+
target1();
39+
for (var i = 0; i < 10000; ++i)
40+
target2();
41+
for (var i = 0; i < 10000; ++i)
42+
target3();

0 commit comments

Comments
 (0)