Skip to content

Commit 4a60684

Browse files
ptomatowebkit-commit-queue
authored andcommitted
[JSC] Implement Temporal
https://bugs.webkit.org/show_bug.cgi?id=223166 Patch by Philip Chimento <pchimento@igalia.com> on 2021-07-06 Reviewed by Yusuke Suzuki. Intended to be the first patch in a stack. Adds boilerplate for Temporal in order to unblock further parallelizable work on this bug. This patch adds a feature flag for Temporal, and a toplevel Temporal global containing only Temporal.now, which is itself an empty object. These objects will be further populated in later patches. * CMakeLists.txt: Add TemporalObject and TemporalNow. Property lookup table in TemporalObject. * DerivedSources.make: Add TemporalObject property lookup table header. * JavaScriptCore.xcodeproj/project.pbxproj: Add new files. * Sources.txt: Add TemporalObject and TemporalNow. * runtime/CommonIdentifiers.h: Add 'Temporal' property key. * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): Create the Temporal global if the feature flag is enabled. * runtime/OptionsList.h: Add useTemporal feature flag. * runtime/TemporalNow.cpp: Added. (JSC::TemporalNow::TemporalNow): (JSC::TemporalNow::create): (JSC::TemporalNow::createStructure): (JSC::TemporalNow::finishCreation): * runtime/TemporalNow.h: Added. * runtime/TemporalObject.cpp: Added. (JSC::createNowObject): (JSC::TemporalObject::TemporalObject): (JSC::TemporalObject::create): (JSC::TemporalObject::createStructure): (JSC::TemporalObject::finishCreation): * runtime/TemporalObject.h: Added. Canonical link: https://commits.webkit.org/239448@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279630 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 4a4d88d commit 4a60684

12 files changed

Lines changed: 291 additions & 0 deletions

File tree

Source/JavaScriptCore/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ set(JavaScriptCore_OBJECT_LUT_SOURCES
107107
runtime/StringPrototype.cpp
108108
runtime/SymbolConstructor.cpp
109109
runtime/SymbolPrototype.cpp
110+
runtime/TemporalObject.cpp
110111

111112
wasm/js/JSWebAssembly.cpp
112113
wasm/js/JSToWasmICCallee.cpp
@@ -1086,6 +1087,8 @@ set(JavaScriptCore_PRIVATE_FRAMEWORK_HEADERS
10861087
runtime/SymbolTable.h
10871088
runtime/SymbolTableOrScopeDepth.h
10881089
runtime/TemplateObjectDescriptor.h
1090+
runtime/TemporalNow.h
1091+
runtime/TemporalObject.h
10891092
runtime/TestRunnerUtils.h
10901093
runtime/ThrowScope.h
10911094
runtime/ToNativeFromValue.h

Source/JavaScriptCore/ChangeLog

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
2021-07-06 Philip Chimento <pchimento@igalia.com>
2+
3+
[JSC] Implement Temporal
4+
https://bugs.webkit.org/show_bug.cgi?id=223166
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
Intended to be the first patch in a stack. Adds boilerplate for
9+
Temporal in order to unblock further parallelizable work on this bug.
10+
11+
This patch adds a feature flag for Temporal, and a toplevel Temporal
12+
global containing only Temporal.now, which is itself an empty object.
13+
These objects will be further populated in later patches.
14+
15+
* CMakeLists.txt: Add TemporalObject and TemporalNow. Property lookup
16+
table in TemporalObject.
17+
* DerivedSources.make: Add TemporalObject property lookup table header.
18+
* JavaScriptCore.xcodeproj/project.pbxproj: Add new files.
19+
* Sources.txt: Add TemporalObject and TemporalNow.
20+
* runtime/CommonIdentifiers.h: Add 'Temporal' property key.
21+
* runtime/JSGlobalObject.cpp:
22+
(JSC::JSGlobalObject::init): Create the Temporal global if the feature
23+
flag is enabled.
24+
* runtime/OptionsList.h: Add useTemporal feature flag.
25+
* runtime/TemporalNow.cpp: Added.
26+
(JSC::TemporalNow::TemporalNow):
27+
(JSC::TemporalNow::create):
28+
(JSC::TemporalNow::createStructure):
29+
(JSC::TemporalNow::finishCreation):
30+
* runtime/TemporalNow.h: Added.
31+
* runtime/TemporalObject.cpp: Added.
32+
(JSC::createNowObject):
33+
(JSC::TemporalObject::TemporalObject):
34+
(JSC::TemporalObject::create):
35+
(JSC::TemporalObject::createStructure):
36+
(JSC::TemporalObject::finishCreation):
37+
* runtime/TemporalObject.h: Added.
38+
139
2021-07-06 Yijia Huang <yijia_huang@apple.com>
240

341
Fix type error in testb3

Source/JavaScriptCore/DerivedSources.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ OBJECT_LUT_HEADERS = \
191191
StringPrototype.lut.h \
192192
SymbolConstructor.lut.h \
193193
SymbolPrototype.lut.h \
194+
TemporalObject.lut.h \
194195
WebAssemblyCompileErrorConstructor.lut.h \
195196
WebAssemblyCompileErrorPrototype.lut.h \
196197
WebAssemblyGlobalConstructor.lut.h \

Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,7 @@
19411941
E3FF75331D9CEA1800C7E16D /* DOMJITGetterSetter.h in Headers */ = {isa = PBXBuildFile; fileRef = E3FF752F1D9CEA1200C7E16D /* DOMJITGetterSetter.h */; settings = {ATTRIBUTES = (Private, ); }; };
19421942
E49DC16C12EF294E00184A1F /* SourceProviderCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E49DC15112EF272200184A1F /* SourceProviderCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
19431943
E49DC16D12EF295300184A1F /* SourceProviderCacheItem.h in Headers */ = {isa = PBXBuildFile; fileRef = E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
1944+
F6F150212693D450004B98EF /* TemporalObject.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = F6F150202693D450004B98EF /* TemporalObject.lut.h */; };
19441945
FE041553252EC0730091EB5D /* SlotVisitorMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = FE041552252EC0730091EB5D /* SlotVisitorMacros.h */; settings = {ATTRIBUTES = (Private, ); }; };
19451946
FE05FAFD1FE4CEDA00093230 /* DeprecatedInspectorValues.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 992D6A111FBD491D000245F4 /* DeprecatedInspectorValues.cpp */; };
19461947
FE086BCA2123DEFB003F2929 /* EntryFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = FE086BC92123DEFA003F2929 /* EntryFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -5280,6 +5281,11 @@
52805281
F692A87D0255597D01FF60F7 /* RegExp.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegExp.cpp; sourceTree = "<group>"; tabWidth = 8; };
52815282
F692A87E0255597D01FF60F7 /* RegExp.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = RegExp.h; sourceTree = "<group>"; tabWidth = 8; };
52825283
F692A8870255597D01FF60F7 /* JSCJSValue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCJSValue.cpp; sourceTree = "<group>"; tabWidth = 8; };
5284+
F6F150182693D33D004B98EF /* TemporalNow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporalNow.h; sourceTree = "<group>"; };
5285+
F6F150192693D33E004B98EF /* TemporalObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporalObject.cpp; sourceTree = "<group>"; };
5286+
F6F1501A2693D33E004B98EF /* TemporalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporalObject.h; sourceTree = "<group>"; };
5287+
F6F1501B2693D33E004B98EF /* TemporalNow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TemporalNow.cpp; sourceTree = "<group>"; };
5288+
F6F150202693D450004B98EF /* TemporalObject.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporalObject.lut.h; sourceTree = "<group>"; };
52835289
F73926918DC64330AFCDF0D7 /* JSSourceCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSourceCode.cpp; sourceTree = "<group>"; };
52845290
FE00262223F3AF33003A358F /* WebAssembly.asm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm.asm; name = WebAssembly.asm; path = llint/WebAssembly.asm; sourceTree = "<group>"; };
52855291
FE041552252EC0730091EB5D /* SlotVisitorMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlotVisitorMacros.h; sourceTree = "<group>"; };
@@ -7003,6 +7009,7 @@
70037009
996B73111BD9FA2C00331B84 /* StringConstructor.lut.h */,
70047010
996B73131BD9FA2C00331B84 /* SymbolConstructor.lut.h */,
70057011
996B73141BD9FA2C00331B84 /* SymbolPrototype.lut.h */,
7012+
F6F150202693D450004B98EF /* TemporalObject.lut.h */,
70067013
533B15DE1DC7F463004D500A /* WasmOps.h */,
70077014
AD2FCC0A1DB59C5900B3E736 /* WebAssemblyCompileErrorConstructor.lut.h */,
70087015
AD2FCC0B1DB59C5900B3E736 /* WebAssemblyCompileErrorPrototype.lut.h */,
@@ -7946,6 +7953,10 @@
79467953
E31179A92288385D00514B2C /* SymbolTableOrScopeDepth.h */,
79477954
BDB4B5E099CD4C1BB3C1CF05 /* TemplateObjectDescriptor.cpp */,
79487955
70ECA6041AFDBEA200449739 /* TemplateObjectDescriptor.h */,
7956+
F6F1501B2693D33E004B98EF /* TemporalNow.cpp */,
7957+
F6F150182693D33D004B98EF /* TemporalNow.h */,
7958+
F6F150192693D33E004B98EF /* TemporalObject.cpp */,
7959+
F6F1501A2693D33E004B98EF /* TemporalObject.h */,
79497960
0FA2C17917D7CF84009D015F /* TestRunnerUtils.cpp */,
79507961
0FA2C17A17D7CF84009D015F /* TestRunnerUtils.h */,
79517962
FE2E6A7A1D6EA5FE0060F896 /* ThrowScope.cpp */,
@@ -10641,6 +10652,7 @@
1064110652
A784A26411D16622005776AC /* SyntaxChecker.h in Headers */,
1064210653
DC7997831CDE9FA0004D4A09 /* TagRegistersMode.h in Headers */,
1064310654
70ECA6091AFDBEA200449739 /* TemplateObjectDescriptor.h in Headers */,
10655+
F6F150212693D450004B98EF /* TemporalObject.lut.h in Headers */,
1064410656
0F24E54F17EE274900ABB217 /* TempRegisterSet.h in Headers */,
1064510657
0F44A7B420BF68D90022B171 /* TerminatedCodeOrigin.h in Headers */,
1064610658
0FA2C17C17D7CF84009D015F /* TestRunnerUtils.h in Headers */,

Source/JavaScriptCore/Sources.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,8 @@ runtime/SymbolObject.cpp
10091009
runtime/SymbolPrototype.cpp
10101010
runtime/SymbolTable.cpp
10111011
runtime/TemplateObjectDescriptor.cpp
1012+
runtime/TemporalNow.cpp
1013+
runtime/TemporalObject.cpp
10121014
runtime/TestRunnerUtils.cpp
10131015
runtime/ThrowScope.cpp
10141016
runtime/TypeLocationCache.cpp

Source/JavaScriptCore/runtime/CommonIdentifiers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
macro(SharedArrayBuffer) \
6262
macro(String) \
6363
macro(Symbol) \
64+
macro(Temporal) \
6465
macro(WeakRef) \
6566
macro(__defineGetter__) \
6667
macro(__defineSetter__) \

Source/JavaScriptCore/runtime/JSGlobalObject.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
#include "SymbolConstructor.h"
202202
#include "SymbolObject.h"
203203
#include "SymbolPrototype.h"
204+
#include "TemporalObject.h"
204205
#include "VMTrapsInlines.h"
205206
#include "WasmCapabilities.h"
206207
#include "WeakMapConstructor.h"
@@ -1217,6 +1218,11 @@ capitalName ## Constructor* lowerName ## Constructor = featureFlag ? capitalName
12171218
IntlObject* intl = IntlObject::create(vm, this, IntlObject::createStructure(vm, this, m_objectPrototype.get()));
12181219
putDirectWithoutTransition(vm, vm.propertyNames->Intl, intl, static_cast<unsigned>(PropertyAttribute::DontEnum));
12191220

1221+
if (Options::useTemporal()) {
1222+
TemporalObject* temporal = TemporalObject::create(vm, TemporalObject::createStructure(vm, this));
1223+
putDirectWithoutTransition(vm, vm.propertyNames->Temporal, temporal, static_cast<unsigned>(PropertyAttribute::DontEnum));
1224+
}
1225+
12201226
m_moduleLoader.initLater(
12211227
[] (const Initializer<JSModuleLoader>& init) {
12221228
auto catchScope = DECLARE_CATCH_SCOPE(init.vm);

Source/JavaScriptCore/runtime/OptionsList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ bool canUseWebAssemblyFastMemory();
549549
v(Bool, useDataIC, false, Normal, nullptr) \
550550
v(Bool, useDataICInOptimizingJIT, false, Normal, nullptr) \
551551
v(Bool, useDataICSharing, false, Normal, nullptr) \
552+
v(Bool, useTemporal, false, Normal, "Expose the Temporal object.") \
552553

553554

554555
enum OptionEquivalence {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (C) 2021 Igalia S.L. All rights reserved.
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
20+
#include "config.h"
21+
#include "TemporalNow.h"
22+
23+
#include "JSGlobalObject.h"
24+
#include "ObjectPrototype.h"
25+
26+
namespace JSC {
27+
28+
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(TemporalNow);
29+
30+
const ClassInfo TemporalNow::s_info = { "Temporal.now", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(TemporalNow) };
31+
32+
TemporalNow::TemporalNow(VM& vm, Structure* structure)
33+
: Base(vm, structure)
34+
{
35+
}
36+
37+
TemporalNow* TemporalNow::create(VM& vm, Structure* structure)
38+
{
39+
TemporalNow* object = new (NotNull, allocateCell<TemporalNow>(vm.heap)) TemporalNow(vm, structure);
40+
object->finishCreation(vm);
41+
return object;
42+
}
43+
44+
Structure* TemporalNow::createStructure(VM& vm, JSGlobalObject* globalObject)
45+
{
46+
return Structure::create(vm, globalObject, globalObject->objectPrototype(), TypeInfo(ObjectType, StructureFlags), info());
47+
}
48+
49+
void TemporalNow::finishCreation(VM& vm)
50+
{
51+
Base::finishCreation(vm);
52+
ASSERT(inherits(vm, info()));
53+
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
54+
}
55+
56+
} // namespace JSC
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (C) 2021 Igalia, S.L. All rights reserved.
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Lesser General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
*/
19+
20+
#pragma once
21+
22+
#include "JSObject.h"
23+
24+
namespace JSC {
25+
26+
class TemporalNow final : public JSNonFinalObject {
27+
public:
28+
using Base = JSNonFinalObject;
29+
30+
template<typename CellType, SubspaceAccess>
31+
static IsoSubspace* subspaceFor(VM& vm)
32+
{
33+
STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(TemporalNow, Base);
34+
return &vm.plainObjectSpace;
35+
}
36+
37+
static TemporalNow* create(VM&, Structure*);
38+
static Structure* createStructure(VM&, JSGlobalObject*);
39+
40+
DECLARE_INFO;
41+
42+
private:
43+
TemporalNow(VM&, Structure*);
44+
void finishCreation(VM&);
45+
};
46+
47+
} // namespace JSC

0 commit comments

Comments
 (0)