| Index: runtime/vm/parser.h
|
| diff --git a/runtime/vm/parser.h b/runtime/vm/parser.h
|
| index 7798edb2cbcbe2c094d71e7298a7f91368affe17..e29f86e05a78aa50a544f8c1e51c22ab419558a6 100644
|
| --- a/runtime/vm/parser.h
|
| +++ b/runtime/vm/parser.h
|
| @@ -44,81 +44,10 @@ class RecursionChecker;
|
| // background compilation, we are not able to evaluate the constants
|
| // so this cache is necessary to support background compilation.
|
| //
|
| -// There are two places a constant can be cached, depending on whether
|
| -// the script is in the vm heap (snapshot) or not.
|
| -//
|
| -// When a script is in the vm heap, we are not able to cache the
|
| -// constants on the script itself (it is read-only) so we cache them
|
| -// in a per-isolate shared map in the object store. In this case the
|
| -// map key is a pair (array) with 2 elements:
|
| -//
|
| -// - key[0] contains the canonicalized url of the script.
|
| -// - key[1] contains the token position of the constant in the script.
|
| -//
|
| -// The VMConstantsMap type is used to implement this per-isolate map.
|
| -//
|
| -// When a script is not in the vm heap, we cache the constants with
|
| -// the script itself. This is helpful during isolate reloading, as it
|
| -// allows us to reference the compile time constants associated with a
|
| -// particular version of a script. In this case the map key is simply
|
| -// the TokenPosition where the constant is defined.
|
| -//
|
| -// The ConstantsMap type is used to implement this per-script map.
|
| -
|
| -// The key for the per-isolate compile time constants map. By using a
|
| -// ValueObject we are able to look up a constant without allocating a
|
| -// key pair (array).
|
| -// The per-script compile-time constants map.
|
| -struct UrlAndPosKey : ValueObject {
|
| - UrlAndPosKey(const String& url, TokenPosition pos)
|
| - : script_url(url), token_pos(pos) { }
|
| - const String& script_url;
|
| - TokenPosition token_pos;
|
| -};
|
| -
|
| -// The per-isolate compile-time constants map.
|
| -class VMConstMapKeyEqualsTraits {
|
| - public:
|
| - static const char* Name() { return "VMConstMapKeyEqualsTraits"; }
|
| - static bool ReportStats() { return false; }
|
| -
|
| - static bool IsMatch(const Object& a, const Object& b) {
|
| - const Array& key1 = Array::Cast(a);
|
| - const Array& key2 = Array::Cast(b);
|
| - // Compare raw strings of script url symbol and raw smi of token positon.
|
| - return (key1.At(0) == key2.At(0)) && (key1.At(1) == key2.At(1));
|
| - }
|
| - static bool IsMatch(const UrlAndPosKey& key1, const Object& b) {
|
| - const Array& key2 = Array::Cast(b);
|
| - // Compare raw strings of script url symbol and token positon.
|
| - return (key1.script_url.raw() == key2.At(0))
|
| - && (key1.token_pos.value() == Smi::Value(Smi::RawCast(key2.At(1))));
|
| - }
|
| - static uword Hash(const Object& obj) {
|
| - const Array& key = Array::Cast(obj);
|
| - intptr_t url_hash = String::HashRawSymbol(String::RawCast(key.At(0)));
|
| - intptr_t pos = Smi::Value(Smi::RawCast(key.At(1)));
|
| - return HashValue(url_hash, pos);
|
| - }
|
| - static uword Hash(const UrlAndPosKey& key) {
|
| - return HashValue(String::HashRawSymbol(key.script_url.raw()),
|
| - key.token_pos.value());
|
| - }
|
| - // Used by CacheConstantValue if a new constant is added to the map.
|
| - static RawObject* NewKey(const UrlAndPosKey& key) {
|
| - const Array& key_obj = Array::Handle(Array::New(2));
|
| - key_obj.SetAt(0, key.script_url);
|
| - key_obj.SetAt(1, Smi::Handle(Smi::New(key.token_pos.value())));
|
| - return key_obj.raw();;
|
| - }
|
| -
|
| - private:
|
| - static uword HashValue(intptr_t url_hash, intptr_t pos) {
|
| - return url_hash * pos % (Smi::kMaxValue - 13);
|
| - }
|
| -};
|
| -typedef UnorderedHashMap<VMConstMapKeyEqualsTraits> VMConstantsMap;
|
| -
|
| +// We cache the constants with the script itself. This is helpful during isolate
|
| +// reloading, as it allows us to reference the compile time constants associated
|
| +// with a particular version of a script. The map key is simply the
|
| +// TokenPosition where the constant is defined.
|
| class ConstMapKeyEqualsTraits {
|
| public:
|
| static const char* Name() { return "ConstMapKeyEqualsTraits"; }
|
|
|