Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (266209 => 266210)
--- trunk/Source/_javascript_Core/ChangeLog 2020-08-27 00:43:30 UTC (rev 266209)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-08-27 01:00:47 UTC (rev 266210)
@@ -1,3 +1,27 @@
+2020-08-26 Alexey Shvayka <[email protected]>
+
+ Use unsigned type for `length` of JSFunction
+ https://bugs.webkit.org/show_bug.cgi?id=215870
+
+ Reviewed by Darin Adler.
+
+ Since the `length` value of a built-in function is its arity,
+ we can communicate it's always non-negative via method signatures.
+
+ No behavior change: `length` values redefined by user code are unaffected.
+
+ * runtime/InternalFunction.cpp:
+ (JSC::InternalFunction::createFunctionThatMasqueradesAsUndefined):
+ * runtime/InternalFunction.h:
+ * runtime/JSFunction.cpp:
+ (JSC::JSFunction::create):
+ (JSC::JSFunction::finishCreation):
+ * runtime/JSFunction.h:
+ * runtime/JSNativeStdFunction.cpp:
+ (JSC::JSNativeStdFunction::finishCreation):
+ (JSC::JSNativeStdFunction::create):
+ * runtime/JSNativeStdFunction.h:
+
2020-08-26 Yusuke Suzuki <[email protected]>
[JSC] Enable Intl.Segmenter
Modified: trunk/Source/_javascript_Core/runtime/InternalFunction.cpp (266209 => 266210)
--- trunk/Source/_javascript_Core/runtime/InternalFunction.cpp 2020-08-27 00:43:30 UTC (rev 266209)
+++ trunk/Source/_javascript_Core/runtime/InternalFunction.cpp 2020-08-27 01:00:47 UTC (rev 266210)
@@ -154,7 +154,7 @@
return baseClass;
}
-InternalFunction* InternalFunction::createFunctionThatMasqueradesAsUndefined(VM& vm, JSGlobalObject* globalObject, int length, const String& name, NativeFunction nativeFunction)
+InternalFunction* InternalFunction::createFunctionThatMasqueradesAsUndefined(VM& vm, JSGlobalObject* globalObject, unsigned length, const String& name, NativeFunction nativeFunction)
{
Structure* structure = Structure::create(vm, globalObject, globalObject->objectPrototype(), TypeInfo(InternalFunctionType, InternalFunction::StructureFlags | MasqueradesAsUndefined), InternalFunction::info());
globalObject->masqueradesAsUndefinedWatchpoint()->fireAll(globalObject->vm(), "Allocated masquerading object");
Modified: trunk/Source/_javascript_Core/runtime/InternalFunction.h (266209 => 266210)
--- trunk/Source/_javascript_Core/runtime/InternalFunction.h 2020-08-27 00:43:30 UTC (rev 266209)
+++ trunk/Source/_javascript_Core/runtime/InternalFunction.h 2020-08-27 01:00:47 UTC (rev 266210)
@@ -58,7 +58,7 @@
}
JS_EXPORT_PRIVATE static Structure* createSubclassStructure(JSGlobalObject*, JSObject* newTarget, Structure*);
- JS_EXPORT_PRIVATE static InternalFunction* createFunctionThatMasqueradesAsUndefined(VM&, JSGlobalObject*, int length, const String& name, NativeFunction);
+ JS_EXPORT_PRIVATE static InternalFunction* createFunctionThatMasqueradesAsUndefined(VM&, JSGlobalObject*, unsigned length, const String& name, NativeFunction);
TaggedNativeFunction nativeFunctionFor(CodeSpecializationKind kind)
{
Modified: trunk/Source/_javascript_Core/runtime/JSFunction.cpp (266209 => 266210)
--- trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2020-08-27 00:43:30 UTC (rev 266209)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.cpp 2020-08-27 01:00:47 UTC (rev 266210)
@@ -85,7 +85,7 @@
return result;
}
-JSFunction* JSFunction::create(VM& vm, JSGlobalObject* globalObject, int length, const String& name, NativeFunction nativeFunction, Intrinsic intrinsic, NativeFunction nativeConstructor, const DOMJIT::Signature* signature)
+JSFunction* JSFunction::create(VM& vm, JSGlobalObject* globalObject, unsigned length, const String& name, NativeFunction nativeFunction, Intrinsic intrinsic, NativeFunction nativeConstructor, const DOMJIT::Signature* signature)
{
NativeExecutable* executable = vm.getHostFunction(nativeFunction, intrinsic, nativeConstructor, signature, name);
Structure* structure = globalObject->hostFunctionStructure();
@@ -114,7 +114,7 @@
ASSERT(methodTable(vm)->getCallData == &JSFunction::getCallData);
}
-void JSFunction::finishCreation(VM& vm, NativeExecutable*, int length, const String& name)
+void JSFunction::finishCreation(VM& vm, NativeExecutable*, unsigned length, const String& name)
{
Base::finishCreation(vm);
ASSERT(inherits(vm, info()));
Modified: trunk/Source/_javascript_Core/runtime/JSFunction.h (266209 => 266210)
--- trunk/Source/_javascript_Core/runtime/JSFunction.h 2020-08-27 00:43:30 UTC (rev 266209)
+++ trunk/Source/_javascript_Core/runtime/JSFunction.h 2020-08-27 01:00:47 UTC (rev 266210)
@@ -80,7 +80,7 @@
static Structure* selectStructureForNewFuncExp(JSGlobalObject*, FunctionExecutable*);
- JS_EXPORT_PRIVATE static JSFunction* create(VM&, JSGlobalObject*, int length, const String& name, NativeFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor, const DOMJIT::Signature* = nullptr);
+ JS_EXPORT_PRIVATE static JSFunction* create(VM&, JSGlobalObject*, unsigned length, const String& name, NativeFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor, const DOMJIT::Signature* = nullptr);
static JSFunction* createWithInvalidatedReallocationWatchpoint(VM&, FunctionExecutable*, JSScope*);
@@ -169,7 +169,7 @@
JS_EXPORT_PRIVATE JSFunction(VM&, NativeExecutable*, JSGlobalObject*, Structure*);
JSFunction(VM&, FunctionExecutable*, JSScope*, Structure*);
- void finishCreation(VM&, NativeExecutable*, int length, const String& name);
+ void finishCreation(VM&, NativeExecutable*, unsigned length, const String& name);
void finishCreation(VM&);
static bool getOwnPropertySlot(JSObject*, JSGlobalObject*, PropertyName, PropertySlot&);
Modified: trunk/Source/_javascript_Core/runtime/JSNativeStdFunction.cpp (266209 => 266210)
--- trunk/Source/_javascript_Core/runtime/JSNativeStdFunction.cpp 2020-08-27 00:43:30 UTC (rev 266209)
+++ trunk/Source/_javascript_Core/runtime/JSNativeStdFunction.cpp 2020-08-27 01:00:47 UTC (rev 266210)
@@ -46,7 +46,7 @@
Base::visitChildren(thisObject, visitor);
}
-void JSNativeStdFunction::finishCreation(VM& vm, NativeExecutable* executable, int length, const String& name)
+void JSNativeStdFunction::finishCreation(VM& vm, NativeExecutable* executable, unsigned length, const String& name)
{
Base::finishCreation(vm, executable, length, name);
ASSERT(inherits(vm, info()));
@@ -59,7 +59,7 @@
return function->function()(globalObject, callFrame);
}
-JSNativeStdFunction* JSNativeStdFunction::create(VM& vm, JSGlobalObject* globalObject, int length, const String& name, NativeStdFunction&& nativeStdFunction, Intrinsic intrinsic, NativeFunction nativeConstructor)
+JSNativeStdFunction* JSNativeStdFunction::create(VM& vm, JSGlobalObject* globalObject, unsigned length, const String& name, NativeStdFunction&& nativeStdFunction, Intrinsic intrinsic, NativeFunction nativeConstructor)
{
NativeExecutable* executable = vm.getHostFunction(runStdFunction, intrinsic, nativeConstructor, nullptr, name);
Structure* structure = globalObject->nativeStdFunctionStructure();
Modified: trunk/Source/_javascript_Core/runtime/JSNativeStdFunction.h (266209 => 266210)
--- trunk/Source/_javascript_Core/runtime/JSNativeStdFunction.h 2020-08-27 00:43:30 UTC (rev 266209)
+++ trunk/Source/_javascript_Core/runtime/JSNativeStdFunction.h 2020-08-27 01:00:47 UTC (rev 266210)
@@ -52,7 +52,7 @@
DECLARE_EXPORT_INFO;
- JS_EXPORT_PRIVATE static JSNativeStdFunction* create(VM&, JSGlobalObject*, int length, const String& name, NativeStdFunction&&, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor);
+ JS_EXPORT_PRIVATE static JSNativeStdFunction* create(VM&, JSGlobalObject*, unsigned length, const String& name, NativeStdFunction&&, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor);
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
@@ -64,7 +64,7 @@
private:
JSNativeStdFunction(VM&, NativeExecutable*, JSGlobalObject*, Structure*, NativeStdFunction&&);
- void finishCreation(VM&, NativeExecutable*, int length, const String& name);
+ void finishCreation(VM&, NativeExecutable*, unsigned length, const String& name);
static void visitChildren(JSCell*, SlotVisitor&);
NativeStdFunction m_function;