- // ECMA 15.5.3.1 String.prototype
- putDirectWithoutTransition(exec->propertyNames().prototype, stringPrototype, ReadOnly | DontEnum | DontDelete);
-
- // ECMA 15.5.3.2 fromCharCode()
-#if ENABLE(JIT) && ENABLE(JIT_OPTIMIZE_NATIVE_CALL)
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, exec->globalData().getThunk(fromCharCodeThunkGenerator), stringFromCharCode), DontEnum);
-#else
- putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum);
-#endif
- // no. of arguments for constructor
- putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
+ unsigned length = exec->argumentCount();
+ StringBuilder builder;
+ builder.reserveCapacity(length);
+
+ for (unsigned i = 0; i < length; ++i) {
+ double codePointAsDouble = exec->uncheckedArgument(i).toNumber(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+
+ uint32_t codePoint = static_cast<uint32_t>(codePointAsDouble);
+
+ if (codePoint != codePointAsDouble || codePoint > UCHAR_MAX_VALUE)
+ return throwVMError(exec, createRangeError(exec, ASCIILiteral("Arguments contain a value that is out of range of code points")));
+
+ if (U_IS_BMP(codePoint))
+ builder.append(static_cast<UChar>(codePoint));
+ else {
+ builder.append(U16_LEAD(codePoint));
+ builder.append(U16_TRAIL(codePoint));
+ }
+ }
+
+ return JSValue::encode(jsString(exec, builder.toString()));