Beispiel #1
0
/* static */ bool
InefficientNonFlatteningStringHashPolicy::match(const JSString *const &k, const Lookup &l)
{
    // We can't use js::EqualStrings, because that flattens our strings.
    if (k->length() != l->length())
        return false;

    const jschar *c1;
    ScopedJSFreePtr<jschar> ownedChars1;
    if (k->hasPureChars()) {
        c1 = k->pureChars();
    } else {
        if (!k->copyNonPureChars(/* tcx */ nullptr, ownedChars1))
            MOZ_CRASH("oom");
        c1 = ownedChars1;
    }

    const jschar *c2;
    ScopedJSFreePtr<jschar> ownedChars2;
    if (l->hasPureChars()) {
        c2 = l->pureChars();
    } else {
        if (!l->copyNonPureChars(/* tcx */ nullptr, ownedChars2))
            MOZ_CRASH("oom");
        c2 = ownedChars2;
    }

    return PodEqual(c1, c2, k->length());
}
Beispiel #2
0
/* static */ bool
MovableCellHasher<T>::match(const Key& k, const Lookup& l)
{
    // Return true if both are null or false if only one is null.
    if (!k)
        return !l;
    if (!l)
        return false;

    MOZ_ASSERT(k);
    MOZ_ASSERT(l);
    MOZ_ASSERT(CurrentThreadCanAccessZone(l->zoneFromAnyThread()) ||
               l->zoneFromAnyThread()->isSelfHostingZone());

    Zone* zone = k->zoneFromAnyThread();
    if (zone != l->zoneFromAnyThread())
        return false;
    MOZ_ASSERT(zone->hasUniqueId(k));
    MOZ_ASSERT(zone->hasUniqueId(l));

    // Since both already have a uid (from hash), the get is infallible.
    uint64_t uidK, uidL;
    MOZ_ALWAYS_TRUE(zone->getUniqueId(k, &uidK));
    MOZ_ALWAYS_TRUE(zone->getUniqueId(l, &uidL));
    return uidK == uidL;
}
Beispiel #3
0
 void parse_group(const Syntax * p, unsigned level) {
   Assoc assoc;
   if (p->is_a("none"))
     assoc = None;
   else if (p->is_a("left"))
     assoc = Left;
   else if (p->is_a("right"))
     assoc = Right;
   else if (p->is_a("list"))
     assoc = List;
   else
     abort();
   for (int i = 0; i != p->num_args(); ++i) {
     if (p->arg(i)->is_a("special")) {
       SpecialOp * op = new SpecialOp;
       op->parse_self(p->arg(i));
       lookup_.insert(Pair<OpKey,OpCommon *>(*op,op));      
     } else {
       Op * op = new Op;
       op->parse_self(p->arg(i));
       op->level = level;
       op->assoc = assoc;
       lookup_.insert(Pair<OpKey,OpCommon *>(*op,op));      
     }
   }
 }
Beispiel #4
0
// Test whether two MDefinitions are congruent.
bool
ValueNumberer::VisibleValues::ValueHasher::match(Key k, Lookup l)
{
    // If one of the instructions depends on a store, and the other instruction
    // does not depend on the same store, the instructions are not congruent.
    if (k->dependency() != l->dependency())
        return false;

    bool congruent = k->congruentTo(l); // Ask the values themselves what they think.
    MOZ_ASSERT(congruent == l->congruentTo(k), "congruentTo relation is not symmetric");
    return congruent;
}
Beispiel #5
0
Lookup::Result* Lookup::findSlotsIn( oop_t rcvr, oop_t selector, LookupType lt ) {
  static bool reentered = false;
  if (reentered) fatal("reentered");
  reentered = true;
  
  static Lookup lp;
  lp.init(selector, lt);
  if (baseLookupType(lt) == ResendBaseLookupType)   lp.findInParentsOf(rcvr, MapObj::from(mapOop(rcvr)));
  else                                              lp.findInObject(rcvr);
  
  reentered = false;
  return &lp.result;
}
Beispiel #6
0
/* static */ HashNumber
MovableCellHasher<T>::hash(const Lookup& l)
{
    if (!l)
        return 0;

    // We have to access the zone from-any-thread here: a worker thread may be
    // cloning a self-hosted object from the main-thread-runtime-owned self-
    // hosting zone into the off-main-thread runtime. The zone's uid lock will
    // protect against multiple workers doing this simultaneously.
    MOZ_ASSERT(CurrentThreadCanAccessZone(l->zoneFromAnyThread()) ||
               l->zoneFromAnyThread()->isSelfHostingZone());

    return l->zoneFromAnyThread()->getHashCodeInfallible(l);
}
Beispiel #7
0
/* static */ bool
InefficientNonFlatteningStringHashPolicy::match(const JSString *const &k, const Lookup &l)
{
    // We can't use js::EqualStrings, because that flattens our strings.
    JSString *s1 = const_cast<JSString *>(k);
    if (k->hasLatin1Chars()) {
        return l->hasLatin1Chars()
               ? EqualStringsPure<Latin1Char, Latin1Char>(s1, l)
               : EqualStringsPure<Latin1Char, jschar>(s1, l);
    }

    return l->hasLatin1Chars()
           ? EqualStringsPure<jschar, Latin1Char>(s1, l)
           : EqualStringsPure<jschar, jschar>(s1, l);
}
Beispiel #8
0
/* static */ HashNumber
InefficientNonFlatteningStringHashPolicy::hash(const Lookup &l)
{
    ScopedJSFreePtr<jschar> ownedChars;
    const jschar *chars;
    if (l->hasPureChars()) {
        chars = l->pureChars();
    } else {
        // Slowest hash function evar!
        if (!l->copyNonPureChars(/* tcx */ nullptr, ownedChars))
            MOZ_CRASH("oom");
        chars = ownedChars;
    }

    return mozilla::HashString(chars, l->length());
}
Beispiel #9
0
/* static */ HashNumber
InefficientNonFlatteningStringHashPolicy::hash(const Lookup &l)
{
    return l->hasLatin1Chars()
           ? HashStringChars<Latin1Char>(l)
           : HashStringChars<jschar>(l);
}
Beispiel #10
0
 Op::Types i_lookup_types(Op::Types res, const OpKey & k, const Syntax * p) const {
     pair<Lookup::const_iterator,Lookup::const_iterator> is
      = lookup_.equal_range(k);
    for( ; is.first != is.second; ++is.first) {
      res |= is.first->second->type;
    }
    return res;
 }
Beispiel #11
0
/* static */ bool
MovableCellHasher<T>::hasHash(const Lookup& l)
{
    if (!l)
        return true;

    return l->zoneFromAnyThread()->hasUniqueId(l);
}
Beispiel #12
0
 const Op * i_lookup(const OpKey & k, int type, const Syntax * p) const {
   pair<Lookup::const_iterator,Lookup::const_iterator> is
     = lookup_.equal_range(k);
   for( ; is.first != is.second; ++is.first)
     if (is.first->second->type == type)
       return static_cast<const Op *>(is.first->second);
   return 0;
 }
Beispiel #13
0
// Test whether two MDefinitions are congruent.
bool
ValueNumberer::VisibleValues::ValueHasher::match(Key k, Lookup l)
{
    // If one of the instructions depends on a store, and the other instruction
    // does not depend on the same store, the instructions are not congruent.
    if (k->dependency() != l->dependency())
        return false;

    bool congruent = k->congruentTo(l); // Ask the values themselves what they think.
#ifdef DEBUG
    if (congruent != l->congruentTo(k)) {
       JitSpew(JitSpew_GVN, "      congruentTo relation is not symmetric between %s%u and %s%u!!",
               k->opName(), k->id(),
               l->opName(), l->id());
    }
#endif
    return congruent;
}
Beispiel #14
0
/* static */ bool
MovableCellHasher<T>::ensureHash(const Lookup& l)
{
    if (!l)
        return true;

    uint64_t unusedId;
    return l->zoneFromAnyThread()->getUniqueId(l, &unusedId);
}
Beispiel #15
0
/* static */ HashNumber
MovableCellHasher<T>::hash(const Lookup& l)
{
    if (!l)
        return 0;

    // We have to access the zone from-any-thread here: a worker thread may be
    // cloning a self-hosted object from the main-thread-runtime-owned self-
    // hosting zone into the off-main-thread runtime. The zone's uid lock will
    // protect against multiple workers doing this simultaneously.
    MOZ_ASSERT(CurrentThreadCanAccessZone(l->zoneFromAnyThread()) ||
               l->zoneFromAnyThread()->isSelfHostingZone());

    HashNumber hn;
    AutoEnterOOMUnsafeRegion oomUnsafe;
    if (!l->zoneFromAnyThread()->getHashCode(l, &hn))
        oomUnsafe.crash("failed to get a stable hash code");
    return hn;
}
Beispiel #16
0
 const Syntax * i_try_special(const OpKey & k, parts_iterator & i, parts_iterator e) {
   pair<Lookup::const_iterator,Lookup::const_iterator> is
     = lookup_.equal_range(k);
    for( ; is.first != is.second; ++is.first) {
      if (is.first->second->type == Op::Special) {
        const SpecialOp * op = static_cast<const SpecialOp *>(is.first->second);
        const Syntax * res = op->match(i, e);
        if (res) return res;
      }
    }
    return NULL;
 }
Beispiel #17
0
		JSONLineReader::JSONLineReader (SeekIStream* input, const Lookup& lookup, const Config& config) :
			LineReader (input, 1024 * 10),
			lookup (lookup),
			row (lookup.count ())
		{
			string	member (config.get ("member", ""));
			string	root (config.get ("root", "row"));

			for (auto i = root.begin (); i != root.end (); ++i)
				this->lookup.next (*i);

			this->member = member.length () > 0 ? member[0] : '.';
		}
int main() {
    std::vector<std::string> fields;
    Lookup l;
    for (std::string line; std::getline(std::cin, line);) {
        #ifdef DEBUTOUGPUT
        Output::debug("line: %s", line.c_str());
        #endif //DEBUTOUTPUT
        split( fields, line, ',' );
        if(fields.size() != 3) {
            Output::warn("invalid number of arguments on line '%s'", line.c_str());
            break;
        }
        std::string id = fields.at(0);
        double latitude = StringToNumber<double>(fields.at(1));
        double longitude = StringToNumber<double>(fields.at(2));
        #ifdef DEBUTOUGPUT
        Output::debug("id: %s, latitude: %f, lontidue: %f", id.c_str(), latitude, longitude);
        #endif //DEBUTOUTPUT
        std::string result = l.lookup(latitude, longitude);
        fprintf(stdout, "%s,%lld,%s\n", id.c_str(), l.getLastMatchBorderid(), result.c_str());
    }
    return 0;
}
Beispiel #19
0
/* static */ bool
MovableCellHasher<T>::match(const Key& k, const Lookup& l)
{
    // Return true if both are null or false if only one is null.
    if (!k)
        return !l;
    if (!l)
        return false;

    MOZ_ASSERT(k);
    MOZ_ASSERT(l);
    MOZ_ASSERT(CurrentThreadCanAccessZone(l->zoneFromAnyThread()) ||
               l->zoneFromAnyThread()->isSelfHostingZone());

    Zone* zone = k->zoneFromAnyThread();
    if (zone != l->zoneFromAnyThread())
        return false;

#ifdef DEBUG
    // Incremental table sweeping means that existing table entries may no
    // longer have unique IDs. We fail the match in that case and the entry is
    // removed from the table later on.
    if (!zone->hasUniqueId(k)) {
        Key key = k;
        MOZ_ASSERT(IsAboutToBeFinalizedUnbarriered(&key));
    }
    MOZ_ASSERT(zone->hasUniqueId(l));
#endif

    uint64_t keyId;
    if (!zone->maybeGetUniqueId(k, &keyId)) {
        // Key is dead and cannot match lookup which must be live.
        return false;
    }

    return keyId == zone->getUniqueIdInfallible(l);
}
Beispiel #20
0
		RegexLineReader::RegexLineReader (SeekIStream* input, Lookup const& lookup, Config const&) :
			LineReader (input),
			regex ("FIXME"),
			row (lookup.count ())
		{
			Int32u group;

			for (auto& key: lookup)
			{
				if (key.length () > 0 && key[0] == '_' && Convert::toInt32u (&index, key.data () + 1, key.length () - 1))
					this->lookup[group] = i->second;

				buffer.clear ();
			}
		}
Beispiel #21
0
 static js::HashNumber hash(const Lookup& l) {
   HashingMatcher hasher;
   return l.match(hasher);
 }
Beispiel #22
0
 static HashNumber hash(Lookup sig) {
     return AddContainerToHash(sig.args(), HashNumber(sig.ret()));
 }
Beispiel #23
0
 static bool match(const WasmAstSig* lhs, Lookup rhs) {
     return lhs->ret() == rhs.ret() && EqualContainers(lhs->args(), rhs.args());
 }
Beispiel #24
0
/* static */ js::HashNumber
js::Thread::Hasher::hash(const Lookup& l)
{
  return mozilla::HashBytes(&l.platformData()->ptThread, sizeof(pthread_t));
}
Beispiel #25
0
		bool	Parser::parseValue (Lexer& lexer, Lookup& lookup, Int32u* slot, const Extractor** output)
		{
			const Extractor*	argument;
			Extractors			arguments;
			const Constant*		constant;
			const Function*		function;
			string				name;
			Float64				number;

			switch (lexer.getType ())
			{
				case Lexer::IDENTIFIER:
					name = lexer.getCurrent ();

					lexer.next ();

					if (lexer.getType () == Lexer::PARENTHESIS_BEGIN)
					{
						function = 0;

						for (Int32u i = 0; Function::functions[i].name; ++i)
						{
							if (Function::functions[i].name == name)
							{
								function = &Function::functions[i];

								break;
							}
						}

						if (!function)
							return this->fail (lexer, string ("unknown function name '") + lexer.getCurrent () + "'");

						lexer.next ();

						while (lexer.getType () != Lexer::PARENTHESIS_END)
						{
							if (arguments.size () > 0 && !this->parseType (lexer, Lexer::COMMA, "argument separator"))
								return false;

							if (!this->parseExpression (lexer, lookup, slot, &argument))
								return false;

							arguments.push_back (argument);
						}

						lexer.next ();

						if (arguments.size () < function->min || (function->max > 0 && arguments.size () > function->max))
							return this->fail (lexer, "wrong number of arguments");

						*output = function->builder (arguments, slot);
					}
					else
					{
						constant = 0;

						for (Int32u i = 0; Constant::constants[i].name; ++i)
						{
							if (Constant::constants[i].name == name)
							{
								constant = &Constant::constants[i];

								break;
							}
						}

						if (constant)
							*output = new ConstantExtractor (constant->value);
						else
							*output = new FieldExtractor (lookup.store (name));
					}

					break;

				case Lexer::NUMBER:
					if (!Convert::toFloat (&number, lexer.getCurrent ().data (), lexer.getCurrent ().length ()))
						return this->fail (lexer, "invalid number");

					*output = new ConstantExtractor (Variant (number));

					lexer.next ();

					break;

				case Lexer::STRING:
					*output = new ConstantExtractor (Variant (lexer.getCurrent ()));

					lexer.next ();

					break;

				default:
					this->fail (lexer, "unexpected character");

					return false;
			}

			this->extractors.push_back (*output);

			return true;
		}
Beispiel #26
0
HashNumber
ValueNumberer::VisibleValues::ValueHasher::hash(Lookup ins)
{
    return ins->valueHash();
}
Beispiel #27
0
 static HashNumber hash(const Lookup& v) { return v.asRawBits(); }
Beispiel #28
0
inline bool
ShapeHasher::match(const Key k, const Lookup l)
{
    return l->matches(k);
}
inline HashNumber
ShapeHasher::hash(const Lookup &l)
{
    return l.hash();
}
void initLookup( Lookup<T,U> &lookup, Spline< T,U > &spline, T xMin, T xMax, unsigned numSamples )
{
	lookup.init( spline, xMin, xMax, numSamples );
}