Skip to content

Commit

Permalink
Merge pull request #24 from rmottola/master
Browse files Browse the repository at this point in the history
Merge another HUGE commit from Riccardo :)
  • Loading branch information
wicknix committed Mar 20, 2019
2 parents 690a3ea + 83e956b commit b1697e8
Show file tree
Hide file tree
Showing 184 changed files with 5,805 additions and 4,179 deletions.
40 changes: 33 additions & 7 deletions TODO.md
Expand Up @@ -28,6 +28,7 @@
- 1223690 - Remove implicit Rect conversions
- 1222516 - 2016-10-20 part 4. Implement support for rel=noopener on links. - apply part3 before
- 1222516 part 3. Rejigger our rel="noreferrer" - unable to apply because of inherit principal vs inherit owner, furthermore nsNullPtr
- Bug 1249787 - 2016-02-20 - BaldrMonkey: Fix wasm string hex escape parsing endiann
- 1219392 - Capitalize mozilla::unused to avoid conflicts
- 1207245 - 2015-10-07 part 6 - rename nsRefPtr<T> to RefPtr<T>
- 1207245 - part 3 - switch all uses of mozilla::RefPtr<T> to nsRefPtr<T>
Expand Down Expand Up @@ -62,29 +63,50 @@
- 1154997 - Deal with self-hosted builtins when stringifying tracke
- 1150654 - Add CantInlineNoSpecialization to distinguish natives f
- 1144366 (big pointer style refactor, see below.... ToDo)
- Bug 1157279. Escaping CSS identifiers should use lowercase letters fo
- 1142669 part 6 - Don't inline scripts that are known to inline a
- 1145440 - Ship constant names for tracked strategy and outcomes i
- 1143860 - Deduplicate tracked optimizations when streaming the pr
- 1142669 part 3 - Limit the total inlined bytecode size to avoid e
- Bug 1134626 part 2 - 2015-04-02 - Move x86 & x64 Architecture into a shared file.
- Bug 1134626 part 1 - 2015-03-31 - Move all x86-shared files into their own directo
- Bug 1135903 - 2015-03-25 - OdinMonkey: Make signal-handler OOB checking an indepen
- Bug 1137180 - Add baseline caches for extensible unboxed objects, and…
- 1142669 - 2015-03-19 part 4 - Fix some inlining issues and inline scripts with
- Bug 1137180 - Add most functionality necessary for extensible unboxed…
- Bug 1144331 - Assert that gray buffering does not depend on isMarking
- Bug 1144369 - Add a GC phase to track time spent buffering gray roots
- Bug 1144789 - Strongly type GrayBufferState enum and move to GCRuntim
- Bug 1144794 - Move markBufferedGrayRoots to the GCRuntime
- Bug 1144811 - Inline the start and end buffering gray roots methods o
- Bug 1144817 - Move hasBufferedGrayRoots to GCRuntim
- Bug 1144832 - Move grayBufferState manipulation out of GCMarker;
- Bug 1144834 - Move resetBufferedGrayRoots to GCRuntime;
- Bug 1144920 - Move gray buffer clearing out of GCMarker
- Bug 1144925 - Buffer gray roots using a CallbackTracer instead of the
- Bug 1144931 - Move gray buffering code to RootMarking.cpp
- Bug 1137180 - Allow unboxed objects to be extended with new propertie…
- Bug 1135897 - 2015-03-13 - Use unboxed objects for JSON objects and constant liter
- Bug 805052 - 2015-03-14 four parts
- Bug 805052 - 2015-03-14 four parts (check all dependencies)
- Bug 1142865 - 2015-03-14 . Remove the parent argument from NewObjectWithGroup.
- Bug 1140670 2015-03-09 all parts
- Bug 1133081 2015-02-15 1 to 5
- Bug 1140586 - 2015-03-12 1 to 5
- Bug 1137180 - Only mark inner scripts as having failed a bounds check…
- Bug 1132522, part 2 - Treat false return from proxyHandler.set()
- Bug 1132522, part 1 - Treat false return from proxyHandler.defineProp
- Bug 928336. Make defining unforgeable properties on objects faster by
- Bug 1131805 1 to 3 parts
- Bug 1136896. Speed up fill() and dedent() by memoizing some of the wo
- Bug 1112164 1 to 19
- Bug 1133746. Allow DOMProxyShadows to communicate to the JIT whether
- Bug 963921 - Clients of the JS API should use JS_DefineElement where
- Bug 1037687, load iframes in shadow DOM
- Bug 1129223 - Remove local mozAfterRemotePaint events



### FIXME / TODO
- Cannot be applied because file is missing - check
Bug 1135825: Add missing MOZ_OVERRIDE annotation in RTCIdentityProvid

Analyze all:
https://bugzilla.mozilla.org/show_bug.cgi?id=1106828

### Further ToDo which would help portability:

- Update code from TemporaryRef to already_Refed
Expand All @@ -101,6 +123,10 @@
- check bugs: bug 1275755, bug 1352874, bug 1440824 as prerequisites for Bug 529808
- Bug 1144366 - Switch SpiderMonkey and XPConnect style from |T *t| to |T* t|

For Windows:
Bug 1135138 - Remove UNICODE from DEFINES in moz.build rather than Ma


### Further Further ToDo:
- import PPC JIT from TenFourFox
- flatten out security manager ssl
Expand Down
4 changes: 2 additions & 2 deletions browser/branding/shared/pref/uaoverrides.inc
Expand Up @@ -15,7 +15,7 @@
#ifndef XP_MACOSX
#define OS_SLICE X11; Linux x86_64;
#else
#define OS_SLICE Macintosh; Intel Mac OS X 10.12;
#define OS_SLICE Macintosh; Intel Mac OS X 10.7;
#endif
#else
#define OS_SLICE Windows NT 6.1; WOW64;
Expand Down Expand Up @@ -47,7 +47,7 @@ pref("@GUAO_PREF@.deviantart.com","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GR
pref("@GUAO_PREF@.deviantart.net","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@");
// UA-Sniffing domains below have indicated no interest in supporting Arctic Fox (BOO!)
pref("@GUAO_PREF@.github.com","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/61.0.2704.79 Safari/537.36 Edge/15.14931");
pref("@GUAO_PREF@.github.com","Mozilla/5.0 (@OS_SLICE@ rv:48.0) @GK_SLICE@ Firefox/48.0");
pref("@GUAO_PREF@.netflix.com","Mozilla/5.0 (@OS_SLICE@ rv:48.0) @GK_SLICE@ Firefox/48.0");
pref("@GUAO_PREF@.netflximg.net","Mozilla/5.0 (@OS_SLICE@ rv:48.0) @GK_SLICE@ Firefox/48.0");
Expand Down
1 change: 1 addition & 0 deletions config/check_spidermonkey_style.py
Expand Up @@ -67,6 +67,7 @@
'js-config.h', # generated in $OBJDIR
'pratom.h', # NSPR
'prcvar.h', # NSPR
'prerror.h', # NSPR
'prinit.h', # NSPR
'prlink.h', # NSPR
'prlock.h', # NSPR
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsContentUtils.h
Expand Up @@ -157,7 +157,7 @@ struct EventNameMapping
{
// This holds pointers to nsGkAtoms members, and is therefore safe as a
// non-owning reference.
nsIAtom* MOZ_OWNING_REF mAtom;
nsIAtom* MOZ_NON_OWNING_REF mAtom;
uint32_t mId;
int32_t mType;
mozilla::EventClassID mEventClassID;
Expand Down
93 changes: 31 additions & 62 deletions dom/bindings/BindingUtils.cpp
Expand Up @@ -1754,31 +1754,6 @@ DictionaryBase::AppendJSONToString(const char16_t* aJSONData,
return true;
}


// Dynamically ensure that two objects don't end up with the same reserved slot.
class MOZ_STACK_CLASS AutoCloneDOMObjectSlotGuard
{
public:
AutoCloneDOMObjectSlotGuard(JSContext* aCx, JSObject* aOld, JSObject* aNew)
: mOldReflector(aCx, aOld), mNewReflector(aCx, aNew)
{
MOZ_ASSERT(js::GetReservedOrProxyPrivateSlot(aOld, DOM_OBJECT_SLOT) ==
js::GetReservedOrProxyPrivateSlot(aNew, DOM_OBJECT_SLOT));
}

~AutoCloneDOMObjectSlotGuard()
{
if (js::GetReservedOrProxyPrivateSlot(mOldReflector, DOM_OBJECT_SLOT).toPrivate()) {
js::SetReservedOrProxyPrivateSlot(mNewReflector, DOM_OBJECT_SLOT,
JS::PrivateValue(nullptr));
}
}

private:
JS::Rooted<JSObject*> mOldReflector;
JS::Rooted<JSObject*> mNewReflector;
};

nsresult
ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg)
{
Expand Down Expand Up @@ -1823,9 +1798,7 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg)
JSAutoCompartment newAc(aCx, newParent);

// First we clone the reflector. We get a copy of its properties and clone its
// expando chain. The only part that is dangerous here is that if we have to
// return early we must avoid ending up with two reflectors pointing to the
// same native. Other than that, the objects we create will just go away.
// expando chain.

JS::Handle<JSObject*> proto = (domClass->mGetProto)(aCx, newParent);
if (!proto) {
Expand All @@ -1837,48 +1810,44 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg)
return NS_ERROR_FAILURE;
}

js::SetReservedOrProxyPrivateSlot(newobj, DOM_OBJECT_SLOT,
js::GetReservedOrProxyPrivateSlot(aObj, DOM_OBJECT_SLOT));

// At this point, both |aObj| and |newobj| point to the same native
// which is bad, because one of them will end up being finalized with a
// native it does not own. |cloneGuard| ensures that if we exit before
// clearing |aObj|'s reserved slot the reserved slot of |newobj| will be
// set to null. |aObj| will go away soon, because we swap it with
// another object during the transplant and let that object die.
JS::Rooted<JSObject*> propertyHolder(aCx);
{
AutoCloneDOMObjectSlotGuard cloneGuard(aCx, aObj, newobj);

JS::Rooted<JSObject*> copyFrom(aCx, isProxy ? expandoObject : aObj);
if (copyFrom) {
propertyHolder = JS_NewObjectWithGivenProto(aCx, nullptr, JS::NullPtr());
if (!propertyHolder) {
return NS_ERROR_OUT_OF_MEMORY;
}

if (!JS_CopyPropertiesFrom(aCx, propertyHolder, copyFrom)) {
return NS_ERROR_FAILURE;
}
} else {
propertyHolder = nullptr;
JS::Rooted<JSObject*> copyFrom(aCx, isProxy ? expandoObject : aObj);
if (copyFrom) {
propertyHolder = JS_NewObjectWithGivenProto(aCx, nullptr, JS::NullPtr());
if (!propertyHolder) {
return NS_ERROR_OUT_OF_MEMORY;
}

// Expandos from other compartments are attached to the target JS object.
// Copy them over, and let the old ones die a natural death.
if (!xpc::XrayUtils::CloneExpandoChain(aCx, newobj, aObj)) {
if (!JS_CopyPropertiesFrom(aCx, propertyHolder, copyFrom)) {
return NS_ERROR_FAILURE;
}
} else {
propertyHolder = nullptr;
}

// We've set up |newobj|, so we make it own the native by nulling
// out the reserved slot of |obj|.
//
// NB: It's important to do this _after_ copying the properties to
// propertyHolder. Otherwise, an object with |foo.x === foo| will
// crash when JS_CopyPropertiesFrom tries to call wrap() on foo.x.
js::SetReservedOrProxyPrivateSlot(aObj, DOM_OBJECT_SLOT, JS::PrivateValue(nullptr));
// Expandos from other compartments are attached to the target JS object.
// Copy them over, and let the old ones die a natural death.

// Note that at this point the DOM_OBJECT_SLOT for |newobj| has not been set.
// CloneExpandoChain() will use this property of |newobj| when it calls
// preserveWrapper() via attachExpandoObject() if |aObj| has expandos set, and
// preserveWrapper() will not do anything in this case. This is safe because
// if expandos are present then the wrapper will already have been preserved
// for this native.
if (!xpc::XrayUtils::CloneExpandoChain(aCx, newobj, aObj)) {
return NS_ERROR_FAILURE;
}

// We've set up |newobj|, so we make it own the native by setting its reserved
// slot and nulling out the reserved slot of |obj|.
//
// NB: It's important to do this _after_ copying the properties to
// propertyHolder. Otherwise, an object with |foo.x === foo| will
// crash when JS_CopyPropertiesFrom tries to call wrap() on foo.x.
js::SetReservedOrProxyPrivateSlot(newobj, DOM_OBJECT_SLOT,
js::GetReservedOrProxyPrivateSlot(aObj, DOM_OBJECT_SLOT));
js::SetReservedOrProxyPrivateSlot(aObj, DOM_OBJECT_SLOT, JS::PrivateValue(nullptr));

aObj = xpc::TransplantObject(aCx, aObj, newobj);
if (!aObj) {
MOZ_CRASH();
Expand Down
102 changes: 71 additions & 31 deletions dom/bindings/Codegen.py
Expand Up @@ -9,6 +9,7 @@
import string
import math
import textwrap
import functools

from WebIDL import BuiltinTypes, IDLBuiltinType, IDLNullValue, IDLSequenceType, IDLType, IDLAttribute, IDLInterfaceMember, IDLUndefinedValue, IDLEmptySequenceValue, IDLDictionary
from Configuration import NoSuchDescriptorError, getTypesFromDescriptor, getTypesFromDictionary, getTypesFromCallback, getAllTypes, Descriptor
Expand Down Expand Up @@ -100,6 +101,24 @@ def indent(s, indentLevel=2):
return re.sub(lineStartDetector, indentLevel * " ", s)


# dedent() and fill() are often called on the same string multiple
# times. We want to memoize their return values so we don't keep
# recomputing them all the time.
def memoize(fn):
"""
Decorator to memoize a function of one argument. The cache just
grows without bound.
"""
cache = {}
@functools.wraps(fn)
def wrapper(arg):
retval = cache.get(arg)
if retval is None:
retval = cache[arg] = fn(arg)
return retval
return wrapper

@memoize
def dedent(s):
"""
Remove all leading whitespace from s, and remove a blank line
Expand All @@ -109,6 +128,54 @@ def dedent(s):
s = s[1:]
return textwrap.dedent(s)


# This works by transforming the fill()-template to an equivalent
# string.Template.
fill_multiline_substitution_re = re.compile(r"( *)\$\*{(\w+)}(\n)?")


@memoize
def compile_fill_template(template):
"""
Helper function for fill(). Given the template string passed to fill(),
do the reusable part of template processing and return a pair (t,
argModList) that can be used every time fill() is called with that
template argument.

argsModList is list of tuples that represent modifications to be
made to args. Each modification has, in order: i) the arg name,
ii) the modified name, iii) the indent depth.
"""
t = dedent(template)
assert t.endswith("\n") or "\n" not in t
argModList = []

def replace(match):
"""
Replaces a line like ' $*{xyz}\n' with '${xyz_n}',
where n is the indent depth, and add a corresponding entry to
argModList.

Note that this needs to close over argModList, so it has to be
defined inside compile_fill_template().
"""
indentation, name, nl = match.groups()
depth = len(indentation)

# Check that $*{xyz} appears by itself on a line.
prev = match.string[:match.start()]
if (prev and not prev.endswith("\n")) or nl is None:
raise ValueError("Invalid fill() template: $*{%s} must appear by itself on a line" % name)

# Now replace this whole line of template with the indented equivalent.
modified_name = name + "_" + str(depth)
argModList.append((name, modified_name, depth))
return "${" + modified_name + "}"

t = re.sub(fill_multiline_substitution_re, replace, t)
return (string.Template(t), argModList)


def fill(template, **args):
"""
Convenience function for filling in a multiline template.
Expand Down Expand Up @@ -138,40 +205,13 @@ def fill(template, **args):
line.
"""

# This works by transforming the fill()-template to an equivalent
# string.Template.
multiline_substitution_re = re.compile(r"( *)\$\*{(\w+)}(\n)?")

def replace(match):
"""
Replaces a line like ' $*{xyz}\n' with '${xyz_n}',
where n is the indent depth, and add a corresponding entry to args.
"""
indentation, name, nl = match.groups()
depth = len(indentation)

# Check that $*{xyz} appears by itself on a line.
prev = match.string[:match.start()]
if (prev and not prev.endswith("\n")) or nl is None:
raise ValueError("Invalid fill() template: $*{%s} must appear by itself on a line" % name)

# Multiline text without a newline at the end is probably a mistake.
t, argModList = compile_fill_template(template)
# Now apply argModList to args
for (name, modified_name, depth) in argModList:
if not (args[name] == "" or args[name].endswith("\n")):
raise ValueError("Argument %s with value %r is missing a newline" % (name, args[name]))
args[modified_name] = indent(args[name], depth)

# Now replace this whole line of template with the indented equivalent.
modified_name = name + "_" + str(depth)
indented_value = indent(args[name], depth)
if modified_name in args:
assert args[modified_name] == indented_value
else:
args[modified_name] = indented_value
return "${" + modified_name + "}"

t = dedent(template)
assert t.endswith("\n") or "\n" not in t
t = re.sub(multiline_substitution_re, replace, t)
t = string.Template(t)
return t.substitute(args)


Expand Down
3 changes: 3 additions & 0 deletions dom/html/moz.build
Expand Up @@ -248,4 +248,7 @@ LOCAL_INCLUDES += [
'/netwerk/base',
]

if CONFIG['MOZ_X11']:
CXXFLAGS += CONFIG['XCFLAGS']

FINAL_LIBRARY = 'xul'
3 changes: 3 additions & 0 deletions gfx/2d/moz.build
Expand Up @@ -176,6 +176,9 @@ CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3', 'gonk', 'qt'):
CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']

if CONFIG['MOZ_X11']:
CXXFLAGS += CONFIG['XCFLAGS']

LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']

if CONFIG['OS_ARCH'] == 'WINNT':
Expand Down
3 changes: 3 additions & 0 deletions gfx/angle/moz.build
Expand Up @@ -166,6 +166,9 @@ EXPORTS.angle.KHR += [ 'include/KHR/khrplatform.h' ]

LOCAL_INCLUDES += [ 'include', 'src' ]

if CONFIG['MOZ_X11']:
CXXFLAGS += CONFIG['XCFLAGS']

if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
NO_VISIBILITY_FLAGS = True

Expand Down

0 comments on commit b1697e8

Please sign in to comment.