RESOLVED FIXED 153792
[JSC] Introduce LinkTimeConstant mechanism
https://bugs.webkit.org/show_bug.cgi?id=153792
Summary [JSC] Introduce LinkTimeConstant mechanism
Yusuke Suzuki
Reported 2016-02-02 11:16:36 PST
...
Attachments
Patch (100.65 KB, patch)
2019-11-02 21:39 PDT, Yusuke Suzuki
no flags
Patch (100.60 KB, patch)
2019-11-02 21:47 PDT, Yusuke Suzuki
no flags
Patch (100.06 KB, patch)
2019-11-02 21:56 PDT, Yusuke Suzuki
no flags
Patch (135.33 KB, patch)
2019-11-03 00:18 PDT, Yusuke Suzuki
no flags
Patch (135.37 KB, patch)
2019-11-03 00:30 PDT, Yusuke Suzuki
no flags
Patch (135.94 KB, patch)
2019-11-03 00:58 PDT, Yusuke Suzuki
no flags
Patch (131.48 KB, patch)
2019-11-03 01:00 PST, Yusuke Suzuki
no flags
Patch (133.83 KB, patch)
2019-11-03 01:58 PST, Yusuke Suzuki
no flags
Patch (135.77 KB, patch)
2019-11-03 01:11 PST, Yusuke Suzuki
no flags
Patch (135.28 KB, patch)
2019-11-03 01:49 PST, Yusuke Suzuki
no flags
Patch (136.50 KB, patch)
2019-11-03 02:14 PST, Yusuke Suzuki
no flags
Patch (138.61 KB, patch)
2019-11-03 17:20 PST, Yusuke Suzuki
no flags
Patch (138.69 KB, patch)
2019-11-03 18:47 PST, Yusuke Suzuki
saam: review+
Yusuke Suzuki
Comment 1 2019-11-02 21:39:05 PDT
Yusuke Suzuki
Comment 2 2019-11-02 21:47:42 PDT
Yusuke Suzuki
Comment 3 2019-11-02 21:56:02 PDT
Yusuke Suzuki
Comment 4 2019-11-03 00:18:52 PDT
Yusuke Suzuki
Comment 5 2019-11-03 00:30:21 PDT
Yusuke Suzuki
Comment 6 2019-11-03 00:58:17 PDT
Yusuke Suzuki
Comment 7 2019-11-03 01:00:45 PST
Yusuke Suzuki
Comment 8 2019-11-03 01:11:17 PST
Yusuke Suzuki
Comment 9 2019-11-03 01:49:27 PST
Yusuke Suzuki
Comment 10 2019-11-03 01:58:41 PST
Yusuke Suzuki
Comment 11 2019-11-03 02:14:34 PST
Yusuke Suzuki
Comment 12 2019-11-03 17:20:14 PST
Yusuke Suzuki
Comment 13 2019-11-03 18:47:50 PST
Saam Barati
Comment 14 2019-11-04 12:20:20 PST
Comment on attachment 382713 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=382713&action=review r=me with a few comments > Source/JavaScriptCore/bytecode/CodeBlock.cpp:903 > + case SourceCodeRepresentation::LinkTimeConstant: maybe we should have global object in the name of this enum value since it's dependent on global object? > Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:838 > + , m_linkTimeConstantRegisters(numberOfLinkTimeConstants, nullptr) This seems wasteful of memory. Any given compile should only have a few of these at most on average. Why not just use a HashMap instead of this Vector? (If we keep the vector, we might as well make it have this as the inline capacity since it's statically known exactly how big the vector will be. But I think HashMap is better.) > Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm:467 > +macro loadConstant(size, index, tag, payload) can other code that branches on if it's a constant use this helper (below in the LLInt)? > Source/JavaScriptCore/llint/LowLevelInterpreter64.asm:469 > +macro loadConstant(size, index, value) can the code below use this as a helper? > Source/JavaScriptCore/runtime/JSGlobalObject.h:423 > + Vector<LazyProperty<JSGlobalObject, JSCell>> m_linkTimeConstants; why not have the correct inline capacity? Or do we really want this out of line? > Source/JavaScriptCore/runtime/JSGlobalObjectInlines.h:113 > +inline JSFunction* JSGlobalObject::throwTypeErrorFunction() const { return bitwise_cast<JSFunction*>(linkTimeConstant(LinkTimeConstant::throwTypeErrorFunction)); } > +inline JSFunction* JSGlobalObject::newPromiseCapabilityFunction() const { return bitwise_cast<JSFunction*>(linkTimeConstant(LinkTimeConstant::newPromiseCapability)); } > +inline JSFunction* JSGlobalObject::resolvePromiseFunction() const { return bitwise_cast<JSFunction*>(linkTimeConstant(LinkTimeConstant::resolvePromise)); } > +inline JSFunction* JSGlobalObject::rejectPromiseFunction() const { return bitwise_cast<JSFunction*>(linkTimeConstant(LinkTimeConstant::rejectPromise)); } > +inline JSFunction* JSGlobalObject::promiseProtoThenFunction() const { return bitwise_cast<JSFunction*>(linkTimeConstant(LinkTimeConstant::defaultPromiseThen)); } > +inline JSFunction* JSGlobalObject::regExpProtoExecFunction() const { return bitwise_cast<JSFunction*>(linkTimeConstant(LinkTimeConstant::regExpBuiltinExec)); } > +inline GetterSetter* JSGlobalObject::regExpProtoGlobalGetter() const { return bitwise_cast<GetterSetter*>(linkTimeConstant(LinkTimeConstant::regExpProtoGlobalGetter)); } > +inline GetterSetter* JSGlobalObject::regExpProtoUnicodeGetter() const { return bitwise_cast<GetterSetter*>(linkTimeConstant(LinkTimeConstant::regExpProtoUnicodeGetter)); } why not static cast for all of these? > LayoutTests/inspector/debugger/tail-deleted-frames/tail-deleted-frames-this-value-expected.txt:17 > + this: c - Why has code you have in this patch changed the backtrace?
Yusuke Suzuki
Comment 15 2019-11-04 18:47:54 PST
Comment on attachment 382713 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=382713&action=review Thanks! >> Source/JavaScriptCore/bytecode/CodeBlock.cpp:903 >> + case SourceCodeRepresentation::LinkTimeConstant: > > maybe we should have global object in the name of this enum value since it's dependent on global object? Talked with Saam. For now, I'll use LinkTimeConstant since it represents constant populated at linking time. >> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:838 >> + , m_linkTimeConstantRegisters(numberOfLinkTimeConstants, nullptr) > > This seems wasteful of memory. Any given compile should only have a few of these at most on average. Why not just use a HashMap instead of this Vector? > (If we keep the vector, we might as well make it have this as the inline capacity since it's statically known exactly how big the vector will be. But I think HashMap is better.) Right. Changed this to HashMap. >> Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm:467 >> +macro loadConstant(size, index, tag, payload) > > can other code that branches on if it's a constant use this helper (below in the LLInt)? Fixed. >> Source/JavaScriptCore/llint/LowLevelInterpreter64.asm:469 >> +macro loadConstant(size, index, value) > > can the code below use this as a helper? Fixed. >> Source/JavaScriptCore/runtime/JSGlobalObject.h:423 >> + Vector<LazyProperty<JSGlobalObject, JSCell>> m_linkTimeConstants; > > why not have the correct inline capacity? Or do we really want this out of line? We cannot get this information in JSGlobalObject.h since it is included and used before generating JSBuiltins.h. We should not use LinkTimeConstant's JSBuiltins.h information here. >> Source/JavaScriptCore/runtime/JSGlobalObjectInlines.h:113 >> +inline GetterSetter* JSGlobalObject::regExpProtoUnicodeGetter() const { return bitwise_cast<GetterSetter*>(linkTimeConstant(LinkTimeConstant::regExpProtoUnicodeGetter)); } > > why not static cast for all of these? I use jsCast for JSFunction while I continue using bitwise_cast for GetterSetter. Using static_cast / jsCast requires complete type declaration of GetterSetter here, but GetterSetter.h is not exposed outside of JSC. >> LayoutTests/inspector/debugger/tail-deleted-frames/tail-deleted-frames-this-value-expected.txt:17 >> + this: c - > > Why has code you have in this patch changed the backtrace? I think this part is not dumping meaningful value before this change. If you change "c" to "d" in this test, this value becomes "test". And "test" as thisValue seems also incorrect. My guess is that this is related to hash table's value. But anyway, I'll file a bug and ask to inspector folks.
Yusuke Suzuki
Comment 16 2019-11-04 18:52:08 PST
Radar WebKit Bug Importer
Comment 17 2019-11-04 18:53:20 PST
Yusuke Suzuki
Comment 18 2019-11-04 19:30:31 PST
I guess Windows build failure is due to broken forwarding header thing
Yusuke Suzuki
Comment 19 2019-11-04 19:32:23 PST
(In reply to Yusuke Suzuki from comment #18) > I guess Windows build failure is due to broken forwarding header thing Yes, seems like it is.
Note You need to log in before you can comment on or make changes to this bug.