Ignore:
Timestamp:
Sep 24, 2008, 5:26:38 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-24 Maciej Stachowiak <[email protected]>

Reviewed by Oliver Hunt.


  • inline JIT fast case of op_neq
  • remove extra level of function call indirection from slow cases of eq and neq


1% speedup on Richards

  • VM/CTI.cpp: (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompileSlowCases):
  • VM/Machine.cpp: (JSC::Machine::privateExecute): (JSC::Machine::cti_op_eq): (JSC::Machine::cti_op_neq):
  • kjs/operations.cpp: (JSC::equal): (JSC::equalSlowCase):
  • kjs/operations.h: (JSC::equalSlowCaseInline):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/operations.h

    r36728 r36876  
    3232  class JSValue;
    3333
     34  // ECMA 11.9.3
    3435  bool equal(ExecState*, JSValue*, JSValue*);
     36  bool equalSlowCase(ExecState*, JSValue*, JSValue*);
     37
     38  ALWAYS_INLINE bool equalSlowCaseInline(ExecState* exec, JSValue* v1, JSValue* v2)
     39  {
     40      ASSERT(!JSImmediate::areBothImmediateNumbers(v1, v2));
     41
     42      do {
     43          if (v1->isNumber() && v2->isNumber())
     44              return v1->uncheckedGetNumber() == v2->uncheckedGetNumber();
     45
     46          bool s1 = v1->isString();
     47          bool s2 = v2->isString();
     48          if (s1 && s2)
     49              return static_cast<JSString*>(v1)->value() == static_cast<JSString*>(v2)->value();
     50
     51          if (v1->isUndefinedOrNull()) {
     52              if (v2->isUndefinedOrNull())
     53                  return true;
     54              if (JSImmediate::isImmediate(v2))
     55                  return false;
     56              return v2->asCell()->structureID()->typeInfo().masqueradesAsUndefined();
     57          }
     58
     59          if (v2->isUndefinedOrNull()) {
     60              if (JSImmediate::isImmediate(v1))
     61                  return false;
     62              return v1->asCell()->structureID()->typeInfo().masqueradesAsUndefined();
     63          }
     64
     65          if (v1->isObject()) {
     66              if (v2->isObject())
     67                  return v1 == v2;
     68              JSValue* p1 = v1->toPrimitive(exec);
     69              if (exec->hadException())
     70                  return false;
     71              v1 = p1;
     72              if (JSImmediate::areBothImmediateNumbers(v1, v2))
     73                  return v1 == v2;
     74              continue;
     75          }
     76
     77          if (v2->isObject()) {
     78              JSValue* p2 = v2->toPrimitive(exec);
     79              if (exec->hadException())
     80                  return false;
     81              v2 = p2;
     82              if (JSImmediate::areBothImmediateNumbers(v1, v2))
     83                  return v1 == v2;
     84              continue;
     85          }
     86
     87          if (s1 || s2) {
     88              double d1 = v1->toNumber(exec);
     89              double d2 = v2->toNumber(exec);
     90              return d1 == d2;
     91          }
     92
     93          if (v1->isBoolean()) {
     94              if (v2->isNumber())
     95                  return static_cast<double>(v1->getBoolean()) == v2->uncheckedGetNumber();
     96          } else if (v2->isBoolean()) {
     97              if (v1->isNumber())
     98                  return v1->uncheckedGetNumber() == static_cast<double>(v2->getBoolean());
     99          }
     100
     101          return v1 == v2;
     102      } while (true);
     103  }
     104
     105
    35106  bool strictEqual(JSValue*, JSValue*);
    36107  bool strictEqualSlowCase(JSValue*, JSValue*);
Note: See TracChangeset for help on using the changeset viewer.