1. 24 Feb, 2019 1 commit
    • Philip Chimento's avatar
      context: Trace atoms · 6d25dbeb
      Philip Chimento authored
      Apparently I forgot to trace these. It didn't affect most of the members
      of GjsAtoms because string atoms are pinned in memory anyway. But the
      symbol atoms only had their symbol descriptions pinned in memory, not
      the symbols themselves. So garbage collections would collect these
      This wasn't obvious because the symbols seem only to be used early in
      the GJS process anyway. It became apparent when running with JS_GC_ZEAL
      (extra garbage collection after every 100 allocations.)
  2. 18 Feb, 2019 2 commits
  3. 15 Feb, 2019 4 commits
  4. 11 Feb, 2019 11 commits
    • Philip Chimento's avatar
      object: Support fields defined in ancestor classes · 9f182bd6
      Philip Chimento authored
      We define a JS property with getter and setter for a GObject field in
      resolve_impl() (where lazy properties are defined) when JS code tries to
      access a field. The getter and setter retrieve the field's GIFieldInfo
      information from a cache, using a key that is built into the getter and
      Because this is done during the resolve operation, and the resolve
      operation can occur multiple times going up the prototype chain, the JS
      property may end up on a prototype that is an ancestor of the object's
      direct prototype. So the GIFieldInfo may end up on any prototype in the
      prototype chain, and so we have to search through the prototype chain
      for it.
      Closes: #223.
    • Philip Chimento's avatar
      wrapperutils: Avoid template policy warning · 643bd164
      Philip Chimento authored
      In cases where the template function pointer parameter type_struct is
      not null in a particular instantiation, GCC will warn about the code
      here that the pointer can never be null. We want to avoid that warning
      because the whole point is that the pointer is always or never null in a
      particular instantiation.
    • Philip Chimento's avatar
      atoms: Make destructor explicit to prevent inlining · 56bbcca0
      Philip Chimento authored
      The GjsAtoms destructor is giant because it calls a JS::Heap destructor
      for every atom. If it is generated implicitly, then GCC complains about
      it being too big to inline. Providing an explicit destructor seems to
      prevent this warning.
    • Philip Chimento's avatar
      jsapi-util-root: Add debug_addr() method for pointer types · ba7fb121
      Philip Chimento authored
      For GjsMaybeOwned<T> where T is a pointer type, we add a debug_addr()
      method which returns the pointer address without triggering a read
      barrier. This is needed for debug methods because we want to be able to
      debug-log things even after they are marked for sweeping. (The read
      barrier will assert in debug mode if the object is already marked for
    • Philip Chimento's avatar
      build: Look for suitable locale to run tests in · 132e55c9
      Philip Chimento authored
      Apparently only newer libcs define a C.UTF-8 locale (see
      https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=636086). Notably, in
      the Freedesktop SDK there is no C.UTF-8 locale.
      This tests using "locale -a" if the C.UTF-8 locale is available, before
      selecting it. If it is not available, we try to find a reasonable
      fallback, preferring English locales in order to make it easier to share
      debug output in bug reports.
    • Philip Chimento's avatar
      debugger: Fix bug in help command · 0336a67b
      Philip Chimento authored
      Logic error while skipping the comment and eval commands.
    • Philip Chimento's avatar
      fundamental: Fix broken hash table · 105a20a9
      Philip Chimento authored
      There was a hash table (attached to the GjsContext using qdata) which
      stored a mapping of void* fundamental instance pointers to JSObject
      instances. This would have broken quite badly as soon as any of those
      JSObjects were moved by the garbage collector.
      Instead we use a JS::GCHashMap, and since it was previously attached to
      the GjsContext anyway we go ahead and make it a member of
      GjsContextPrivate. We put it inside a JS::WeakCache so that it will be
      automatically swept when the objects are garbage collected.
      The WeakCache must be destroyed before calling JS_DestroyContext() or we
      will fail an assertion in debug mode.
    • Philip Chimento's avatar
      boxed: Remove zero_args_constructor_name member · 0decc66c
      Philip Chimento authored
      This was not actually used anywhere, as the zero-args constructor is
      invoked directly with g_function_info_invoke().
    • Philip Chimento's avatar
      object: Use is_custom_js_class() for readability · f3a94631
      Philip Chimento authored
      This expresses the intention more clearly than checking if info() is
    • Philip Chimento's avatar
      repo: Factor out new function · fc791300
      Philip Chimento authored
      The combination of gjs_lookup_generic_prototype() plus
      JS_NewObjectWithGivenProto() occurs often enough to be a separate
    • Philip Chimento's avatar
      object: Cache field info during resolve already · dce837ce
      Philip Chimento authored
      In object resolve (lazy property definition), we define a JS property
      for a GObject field, and give the property getter and setter a key with
      which it can look up its GIFieldInfo in a cache.
      Previously, the getter and setter would look in the cache, and if the
      GIFieldInfo was not present, compute it from the object's GIObjectInfo
      and add it to the cache.
      Since resolution of a GObject field will always be followed immediately
      by either a getter or setter invocation, and we already have the
      GIFieldInfo available at the resolve step, go ahead and add it to the
      cache already, instead of discarding it and computing it again shortly
      See also: gjs#223
  5. 05 Feb, 2019 5 commits
  6. 31 Jan, 2019 1 commit
  7. 28 Jan, 2019 3 commits
    • Philip Chimento's avatar
      overrides: Allow DBus methods with file descriptor lists · a13bb7a0
      Philip Chimento authored
      For DBus proxies, we now allow calling methods with an extra
      Gio.UnixFDList argument. This does not break existing code because we
      already allowed a bunch of arguments in any order. Gio.DBusProxy.call()
      is the same under the hood as Gio.DBusProxy.call_with_unix_fd_list(),
      only with a null FD list parameter, so we can replace the former with
      the latter.
      Previously, synchronously called DBus proxy methods would return an
      unpacked GVariant. Now, if called with a Gio.UnixFDList they will return
      [unpacked GVariant, FDList]. This also does not break existing code
      because it was not possible to call a method with an FDList before, and
      the return value is unchanged if not calling with an FDList. This does
      mean, unfortunately, that if you have a method with an 'h' in its return
      signature but not in its argument signatures, you will have to call it
      with an empty FDList in order to receive an FDList with the return
      value, if calling synchronously.
      On the DBus service side, when receiving a method call, we now pass the
      FDList received from DBus to the called method. Previously, sync methods
      were passed the parameters, and async methods were passed the parameters
      plus the Gio.DBusInvocation object. Appending the Gio.UnixFDList to
      those parameters also should not break existing code, although it could
      if the method examines the number of arguments. (That is unlikely, since
      DBus doesn't have methods with variable arguments.)
      TODO: Check whether this works on non-Unix platforms.
      Closes #204.
    • Philip Chimento's avatar
      Merge branch 'gjs-private-sources-should-be-c-files' into 'master' · 7b9d03de
      Philip Chimento authored
      GjsPrivate: Sources should be C files
      See merge request GNOME/gjs!262
    • Philip Chimento's avatar
      GjsPrivate: Sources should be C files · e1c96788
      Philip Chimento authored
      The GjsPrivate library doesn't use any SpiderMonkey code, only C APIs.
      So the files should be compiled with a C compiler, otherwise we get
      C++'s stricter typechecks, making it hard to use void* APIs such as
      [skip cpplint] - This shows a diff in the linter output because the
      files were renamed.
  8. 21 Jan, 2019 4 commits
  9. 08 Jan, 2019 3 commits
  10. 02 Jan, 2019 6 commits
    • Philip Chimento's avatar
      gtype: Remove unused function · 886a9a17
      Philip Chimento authored
      With the new GI wrapper framework, this function is now not used.
    • Philip Chimento's avatar
      union: Split private struct into UnionPrototype/UnionInstance · cc2e68cb
      Philip Chimento authored
      This continues the ports of GObject introspection wrappers to the new
      framework introduced in wrapperutils.h.
    • Philip Chimento's avatar
      interface: Split private struct into InterfacePrototype/InterfaceInstance · 0fa00d49
      Philip Chimento authored
      This continues the ports of GObject introspection wrappers to the new
      framework introduced in wrapperutils.h. This file is a bit unusual as no
      InterfaceInstance instances should ever be constructed, so we override
      InterfaceInstance::constructor() to throw an exception.
      This also adds a debug topic for interfaces, since there wasn't one
    • Philip Chimento's avatar
      gerror: Split private struct into ErrorPrototype/ErrorInstance · 603b695a
      Philip Chimento authored
      This continues the ports of GObject introspection wrappers to the new
      framework introduced in wrapperutils.h.
      As part of being ported to the new code, GError objects now gain a
      $gtype property, as all the rest of the GObject introspection wrappers
      have. This property will always be equal to G_TYPE_ERROR.
    • Philip Chimento's avatar
      fundamental: Port private struct to wrapperutils · 36ff0d37
      Philip Chimento authored
      The private struct for Fundamental was already split into
      FundamentalInstance and FundamentalPrototype, but here we port it to the
      framework introduced in the previous commits in wrapperutils.cpp.
    • Philip Chimento's avatar
      boxed: Split private struct into BoxedPrototype/BoxedInstance · 64d769a1
      Philip Chimento authored
      This splits the private struct from boxed.cpp into BoxedPrototype and
      BoxedInstance, as we do with ObjectPrototype and ObjectInstance. The
      memory efficiency gains are less here, as there are only O(1%) as many
      Boxed instances created as Object instances during a typical gnome-shell
      run, but this does prevent the copy assignment operator from being
      implicitly called as it was previously.
      This adds a new feature to the wrapperutils templates: the prototype
      structs are now allocated using GLib's atomic reference count boxes.
      (This does add 16 bytes to every prototype struct, but since the number
      of prototypes allocated is quite small compared to the number of
      instances, this is relatively inconsequential.)
      We should have probably been doing this all along with ObjectPrototype,
      as the m_proto pointer can become dangling if the prototype JSObject is
      garbage collected before any instance JSObjects. This actually happens
      in the Boxed tests, and the information from the prototype is required
      in order to free the instance.
      Closes: #215