diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
commit | 41386e9cb918eed93b3f13648cbef387e371e451 (patch) | |
tree | a97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/JavaScriptCore/runtime/DateConstructor.cpp | |
parent | e15dd966d523731101f70ccf768bba12435a0208 (diff) | |
download | WebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz |
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/JavaScriptCore/runtime/DateConstructor.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/DateConstructor.cpp | 83 |
1 files changed, 29 insertions, 54 deletions
diff --git a/Source/JavaScriptCore/runtime/DateConstructor.cpp b/Source/JavaScriptCore/runtime/DateConstructor.cpp index ee656a309..7cbea6407 100644 --- a/Source/JavaScriptCore/runtime/DateConstructor.cpp +++ b/Source/JavaScriptCore/runtime/DateConstructor.cpp @@ -29,15 +29,15 @@ #include "JSFunction.h" #include "JSGlobalObject.h" #include "JSString.h" +#include "JSStringBuilder.h" #include "ObjectPrototype.h" -#include "JSCInlines.h" +#include "Operations.h" #include <math.h> #include <time.h> #include <wtf/MathExtras.h> -#if ENABLE(WEB_REPLAY) -#include "InputCursor.h" -#include "JSReplayInputs.h" +#if OS(WINCE) +extern "C" time_t time(time_t* timer); // Provided by libce. #endif #if HAVE(SYS_TIME_H) @@ -52,8 +52,9 @@ using namespace WTF; namespace JSC { -EncodedJSValue JSC_HOST_CALL dateParse(ExecState*); -EncodedJSValue JSC_HOST_CALL dateUTC(ExecState*); +static EncodedJSValue JSC_HOST_CALL dateParse(ExecState*); +static EncodedJSValue JSC_HOST_CALL dateNow(ExecState*); +static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState*); } @@ -61,7 +62,7 @@ EncodedJSValue JSC_HOST_CALL dateUTC(ExecState*); namespace JSC { -const ClassInfo DateConstructor::s_info = { "Function", &InternalFunction::s_info, &dateConstructorTable, CREATE_METHOD_TABLE(DateConstructor) }; +const ClassInfo DateConstructor::s_info = { "Function", &InternalFunction::s_info, 0, ExecState::dateConstructorTable, CREATE_METHOD_TABLE(DateConstructor) }; /* Source for DateConstructor.lut.h @begin dateConstructorTable @@ -71,28 +72,6 @@ const ClassInfo DateConstructor::s_info = { "Function", &InternalFunction::s_inf @end */ -#if ENABLE(WEB_REPLAY) -static double deterministicCurrentTime(JSGlobalObject* globalObject) -{ - double currentTime = jsCurrentTime(); - InputCursor& cursor = globalObject->inputCursor(); - if (cursor.isCapturing()) - cursor.appendInput<GetCurrentTime>(currentTime); - - if (cursor.isReplaying()) { - if (GetCurrentTime* input = cursor.fetchInput<GetCurrentTime>()) - currentTime = input->currentTime(); - } - return currentTime; -} -#endif - -#if ENABLE(WEB_REPLAY) -#define NORMAL_OR_DETERMINISTIC_FUNCTION(a, b) (b) -#else -#define NORMAL_OR_DETERMINISTIC_FUNCTION(a, b) (a) -#endif - STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(DateConstructor); DateConstructor::DateConstructor(VM& vm, Structure* structure) @@ -109,7 +88,7 @@ void DateConstructor::finishCreation(VM& vm, DatePrototype* datePrototype) bool DateConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot &slot) { - return getStaticFunctionSlot<InternalFunction>(exec, dateConstructorTable, jsCast<DateConstructor*>(object), propertyName, slot); + return getStaticFunctionSlot<InternalFunction>(exec, ExecState::dateConstructorTable(exec->vm()), jsCast<DateConstructor*>(object), propertyName, slot); } // ECMA 15.9.3 @@ -121,7 +100,7 @@ JSObject* constructDate(ExecState* exec, JSGlobalObject* globalObject, const Arg double value; if (numArgs == 0) // new Date() ECMA 15.9.3.3 - value = NORMAL_OR_DETERMINISTIC_FUNCTION(jsCurrentTime(), deterministicCurrentTime(globalObject)); + value = jsCurrentTime(); else if (numArgs == 1) { if (args.at(0).inherits(DateInstance::info())) value = asDateInstance(args.at(0))->internalNumber(); @@ -142,14 +121,14 @@ JSObject* constructDate(ExecState* exec, JSGlobalObject* globalObject, const Arg args.at(5).toNumber(exec), args.at(6).toNumber(exec) }; - if ((!std::isfinite(doubleArguments[0]) || (doubleArguments[0] > INT_MAX) || (doubleArguments[0] < INT_MIN)) - || (!std::isfinite(doubleArguments[1]) || (doubleArguments[1] > INT_MAX) || (doubleArguments[1] < INT_MIN)) - || (numArgs >= 3 && (!std::isfinite(doubleArguments[2]) || (doubleArguments[2] > INT_MAX) || (doubleArguments[2] < INT_MIN))) - || (numArgs >= 4 && (!std::isfinite(doubleArguments[3]) || (doubleArguments[3] > INT_MAX) || (doubleArguments[3] < INT_MIN))) - || (numArgs >= 5 && (!std::isfinite(doubleArguments[4]) || (doubleArguments[4] > INT_MAX) || (doubleArguments[4] < INT_MIN))) - || (numArgs >= 6 && (!std::isfinite(doubleArguments[5]) || (doubleArguments[5] > INT_MAX) || (doubleArguments[5] < INT_MIN))) - || (numArgs >= 7 && (!std::isfinite(doubleArguments[6]) || (doubleArguments[6] > INT_MAX) || (doubleArguments[6] < INT_MIN)))) - value = PNaN; + if (!std::isfinite(doubleArguments[0]) + || !std::isfinite(doubleArguments[1]) + || (numArgs >= 3 && !std::isfinite(doubleArguments[2])) + || (numArgs >= 4 && !std::isfinite(doubleArguments[3])) + || (numArgs >= 5 && !std::isfinite(doubleArguments[4])) + || (numArgs >= 6 && !std::isfinite(doubleArguments[5])) + || (numArgs >= 7 && !std::isfinite(doubleArguments[6]))) + value = QNaN; else { GregorianDateTime t; int year = JSC::toInt32(doubleArguments[0]); @@ -195,21 +174,17 @@ CallType DateConstructor::getCallData(JSCell*, CallData& callData) return CallTypeHost; } -EncodedJSValue JSC_HOST_CALL dateParse(ExecState* exec) +static EncodedJSValue JSC_HOST_CALL dateParse(ExecState* exec) { return JSValue::encode(jsNumber(parseDate(exec->vm(), exec->argument(0).toString(exec)->value(exec)))); } -EncodedJSValue JSC_HOST_CALL dateNow(ExecState* exec) +static EncodedJSValue JSC_HOST_CALL dateNow(ExecState*) { -#if !ENABLE(WEB_REPLAY) - UNUSED_PARAM(exec); -#endif - - return JSValue::encode(jsNumber(NORMAL_OR_DETERMINISTIC_FUNCTION(jsCurrentTime(), deterministicCurrentTime(exec->lexicalGlobalObject())))); + return JSValue::encode(jsNumber(jsCurrentTime())); } -EncodedJSValue JSC_HOST_CALL dateUTC(ExecState* exec) +static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState* exec) { double doubleArguments[7] = { exec->argument(0).toNumber(exec), @@ -221,13 +196,13 @@ EncodedJSValue JSC_HOST_CALL dateUTC(ExecState* exec) exec->argument(6).toNumber(exec) }; int n = exec->argumentCount(); - if ((std::isnan(doubleArguments[0]) || (doubleArguments[0] > INT_MAX) || (doubleArguments[0] < INT_MIN)) - || (std::isnan(doubleArguments[1]) || (doubleArguments[1] > INT_MAX) || (doubleArguments[1] < INT_MIN)) - || (n >= 3 && (std::isnan(doubleArguments[2]) || (doubleArguments[2] > INT_MAX) || (doubleArguments[2] < INT_MIN))) - || (n >= 4 && (std::isnan(doubleArguments[3]) || (doubleArguments[3] > INT_MAX) || (doubleArguments[3] < INT_MIN))) - || (n >= 5 && (std::isnan(doubleArguments[4]) || (doubleArguments[4] > INT_MAX) || (doubleArguments[4] < INT_MIN))) - || (n >= 6 && (std::isnan(doubleArguments[5]) || (doubleArguments[5] > INT_MAX) || (doubleArguments[5] < INT_MIN))) - || (n >= 7 && (std::isnan(doubleArguments[6]) || (doubleArguments[6] > INT_MAX) || (doubleArguments[6] < INT_MIN)))) + if (std::isnan(doubleArguments[0]) + || std::isnan(doubleArguments[1]) + || (n >= 3 && std::isnan(doubleArguments[2])) + || (n >= 4 && std::isnan(doubleArguments[3])) + || (n >= 5 && std::isnan(doubleArguments[4])) + || (n >= 6 && std::isnan(doubleArguments[5])) + || (n >= 7 && std::isnan(doubleArguments[6]))) return JSValue::encode(jsNaN()); GregorianDateTime t; |