Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Unified Diff: src/js/date.js

Issue 1448933002: Introduce a BuiltinsConstructStub that sets up new.target and does a [[call]] per ES6 9.3.2 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/js/macros.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/date.js
diff --git a/src/js/date.js b/src/js/date.js
index a99d8e4d51fec8cf3f68f36539ae16ce1133c226..6f004c351f0c5a02b2379ae6179ebe54ed9586cf 100644
--- a/src/js/date.js
+++ b/src/js/date.js
@@ -132,7 +132,7 @@ var Date_cache = {
function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
- if (!%_IsConstructCall()) {
+ if (IS_UNDEFINED(new.target)) {
// ECMA 262 - 15.9.2
return %_Call(DateToString, new GlobalDate());
}
@@ -140,9 +140,11 @@ function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
// ECMA 262 - 15.9.3
var argc = %_ArgumentsLength();
var value;
+ var result;
if (argc == 0) {
value = %DateCurrentTime();
- SET_UTC_DATE_VALUE(this, value);
+ result = %NewObject(GlobalDate, new.target);
+ SET_UTC_DATE_VALUE(result, value);
} else if (argc == 1) {
if (IS_NUMBER(year)) {
value = TimeClip(year);
@@ -169,7 +171,8 @@ function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
var time = TO_PRIMITIVE(year);
value = IS_STRING(time) ? DateParse(time) : TO_NUMBER(time);
}
- SET_UTC_DATE_VALUE(this, value);
+ result = %NewObject(GlobalDate, new.target);
+ SET_UTC_DATE_VALUE(result, value);
} else {
year = TO_NUMBER(year);
month = TO_NUMBER(month);
@@ -184,8 +187,11 @@ function DateConstructor(year, month, date, hours, minutes, seconds, ms) {
var day = MakeDay(year, month, date);
var time = MakeTime(hours, minutes, seconds, ms);
value = MakeDate(day, time);
- SET_LOCAL_DATE_VALUE(this, value);
+ result = %NewObject(GlobalDate, new.target);
+ SET_LOCAL_DATE_VALUE(result, value);
}
+
+ return result;
}
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/js/macros.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698