Bug 1629791 part 4 - Stop generating implementations forwarding to the base class. r=iain
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 17 Apr 2020 07:58:26 +0000
changeset 524558 219a8f2d153f89cb8d93939f5a942e69ebc65036
parent 524557 b7332cecb58ab71f5e36bfdddb9817b06be0ae7e
child 524559 667744615032982f90e8f4e5d38a0c403371a7d0
push id37323
push userdluca@mozilla.com
push dateFri, 17 Apr 2020 16:25:55 +0000
treeherdermozilla-central@b4b1d6f91ef0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersiain
bugs1629791
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1629791 part 4 - Stop generating implementations forwarding to the base class. r=iain For ops that are implemented in the base class, we used to generate an emitFoo implementation in BaselineCacheIRCompiler and IonCacheIRCompiler that forwarded to the base class method. Now that we can easily codegen, it's nicer to generate a list of unshared ops and use it so that we can call the base class methods directly. This generates a lot less C++ code in the CacheIR compilers and is easier on the C++ compiler. Eventually both the shared and unshared lists will be replaced with generated boilerplate, but for now this is an improvement. Differential Revision: https://phabricator.services.mozilla.com/D71140
js/src/jit/BaselineCacheIRCompiler.cpp
js/src/jit/BaselineCacheIRCompiler.h
js/src/jit/GenerateCacheIRFiles.py
js/src/jit/IonCacheIRCompiler.cpp
js/src/jit/IonCacheIRCompiler.h
--- a/js/src/jit/BaselineCacheIRCompiler.cpp
+++ b/js/src/jit/BaselineCacheIRCompiler.cpp
@@ -47,23 +47,16 @@ BaseValueIndex CacheRegisterAllocator::a
 BaselineCacheIRCompiler::BaselineCacheIRCompiler(
     JSContext* cx, const CacheIRWriter& writer, uint32_t stubDataOffset,
     BaselineCacheIRStubKind stubKind)
     : CacheIRCompiler(cx, writer, stubDataOffset, Mode::Baseline,
                       StubFieldPolicy::Address),
       makesGCCalls_(false),
       kind_(stubKind) {}
 
-#define DEFINE_SHARED_OP(op)                 \
-  bool BaselineCacheIRCompiler::emit##op() { \
-    return CacheIRCompiler::emit##op();      \
-  }
-CACHE_IR_SHARED_OPS(DEFINE_SHARED_OP)
-#undef DEFINE_SHARED_OP
-
 // AutoStubFrame methods
 AutoStubFrame::AutoStubFrame(BaselineCacheIRCompiler& compiler)
     : compiler(compiler)
 #ifdef DEBUG
       ,
       framePushedAtEnterStubFrame_(0)
 #endif
 {
--- a/js/src/jit/BaselineCacheIRCompiler.h
+++ b/js/src/jit/BaselineCacheIRCompiler.h
@@ -85,17 +85,17 @@ class MOZ_RAII BaselineCacheIRCompiler :
 
   JitCode* compile();
 
   bool makesGCCalls() const;
 
   Address stubAddress(uint32_t offset) const;
 
  private:
-#define DEFINE_OP(op, ...) MOZ_MUST_USE bool emit##op();
-  CACHE_IR_OPS(DEFINE_OP)
+#define DEFINE_OP(op) MOZ_MUST_USE bool emit##op();
+  CACHE_IR_UNSHARED_OPS(DEFINE_OP)
 #undef DEFINE_OP
 };
 
 }  // namespace jit
 }  // namespace js
 
 #endif /* jit_BaselineCacheIRCompiler_h */
--- a/js/src/jit/GenerateCacheIRFiles.py
+++ b/js/src/jit/GenerateCacheIRFiles.py
@@ -61,23 +61,18 @@ def generate_cacheirops_header(c_out, ya
     """Generate CacheIROpsGenerated.h from CacheIROps.yaml. The generated file
     has a list of CacheIR ops, like this:
 
         #define CACHE_IR_OPS(_)\
         _(GuardToObject, Id)\
         _(CompareObjectUndefinedNullResult, Id, Byte)\
         ...
 
-    It also contains a list of "shared" ops (implemented in the CacheIRCompiler
-    base class):
-
-        #define CACHE_IR_SHARED_OPS(_)\
-        _(GuardToObject)\
-        _(GuardIsObjectOrNull)\
-        ...
+    It also contains lists of shared and unshared ops. See the 'shared'
+    attribute in the YAML file.
     """
 
     data = load_yaml(yaml_path)
 
     # Mapping from operand types to the less precise types expected by current
     # C++ code.
     mapping = {
         'ValId': 'Id',
@@ -118,16 +113,17 @@ def generate_cacheirops_header(c_out, ya
         'UInt32Imm': 'UInt32',
 
         'JSNativeImm': 'Word',
         'StaticStringImm': 'Word',
     }
 
     ops_items = []
     ops_shared = []
+    ops_unshared = []
     for op in data:
         name = op['name']
 
         operands = op['operands']
         assert operands is None or isinstance(operands, OrderedDict)
 
         shared = op['shared']
         assert isinstance(shared, bool)
@@ -135,18 +131,24 @@ def generate_cacheirops_header(c_out, ya
         if operands:
             operands_str = ', '.join([mapping[v] for v in operands.values()])
         else:
             operands_str = 'None'
         ops_items.append('_({}, {})'.format(name, operands_str))
 
         if shared:
             ops_shared.append('_({})'.format(name))
+        else:
+            ops_unshared.append('_({})'.format(name))
 
     contents = '#define CACHE_IR_OPS(_)\\\n'
     contents += '\\\n'.join(ops_items)
     contents += '\n\n'
 
     contents += '#define CACHE_IR_SHARED_OPS(_)\\\n'
     contents += '\\\n'.join(ops_shared)
     contents += '\n\n'
 
+    contents += '#define CACHE_IR_UNSHARED_OPS(_)\\\n'
+    contents += '\\\n'.join(ops_unshared)
+    contents += '\n\n'
+
     generate_header(c_out, 'jit_CacheIROpsGenerated_h', contents)
--- a/js/src/jit/IonCacheIRCompiler.cpp
+++ b/js/src/jit/IonCacheIRCompiler.cpp
@@ -104,21 +104,16 @@ AutoSaveLiveRegisters::~AutoSaveLiveRegi
   compiler_.allocator.restoreIonLiveRegisters(compiler_.masm,
                                               compiler_.liveRegs_.ref());
   MOZ_ASSERT(compiler_.masm.framePushed() == compiler_.ionScript_->frameSize());
 }
 
 }  // namespace jit
 }  // namespace js
 
-#define DEFINE_SHARED_OP(op) \
-  bool IonCacheIRCompiler::emit##op() { return CacheIRCompiler::emit##op(); }
-CACHE_IR_SHARED_OPS(DEFINE_SHARED_OP)
-#undef DEFINE_SHARED_OP
-
 void CacheRegisterAllocator::saveIonLiveRegisters(MacroAssembler& masm,
                                                   LiveRegisterSet liveRegs,
                                                   Register scratch,
                                                   IonScript* ionScript) {
   // We have to push all registers in liveRegs on the stack. It's possible we
   // stored other values in our live registers and stored operands on the
   // stack (where our live registers should go), so this requires some careful
   // work. Try to keep it simple by taking one small step at a time.
--- a/js/src/jit/IonCacheIRCompiler.h
+++ b/js/src/jit/IonCacheIRCompiler.h
@@ -66,17 +66,17 @@ class MOZ_RAII IonCacheIRCompiler : publ
   MOZ_MUST_USE bool emitCallNativeGetterResultShared(
       TypedOrValueRegister receiver, const AutoOutputRegister& output,
       AutoSaveLiveRegisters& save);
 
   bool needsPostBarrier() const;
 
   void pushStubCodePointer();
 
-#define DEFINE_OP(op, ...) MOZ_MUST_USE bool emit##op();
-  CACHE_IR_OPS(DEFINE_OP)
+#define DEFINE_OP(op) MOZ_MUST_USE bool emit##op();
+  CACHE_IR_UNSHARED_OPS(DEFINE_OP)
 #undef DEFINE_OP
 };
 
 }  // namespace jit
 }  // namespace js
 
 #endif /* jit_IonCacheIRCompiler_h */