/*
- * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include "config.h"
#include "DFGCommon.h"
-#if ENABLE(DFG_JIT)
-
#include "DFGNode.h"
#include "JSCInlines.h"
+#include <wtf/PrintStream.h>
+
+#if ENABLE(DFG_JIT)
namespace JSC { namespace DFG {
+static StaticSpinLock crashLock;
+
void startCrashing()
{
-#if ENABLE(COMPARE_AND_SWAP)
- static unsigned lock;
- while (!WTF::weakCompareAndSwap(&lock, 0, 1))
- std::this_thread::yield();
-#endif
+ crashLock.lock();
+}
+
+bool isCrashing()
+{
+ return crashLock.isLocked();
+}
+
+bool stringLessThan(StringImpl& a, StringImpl& b)
+{
+ unsigned minLength = std::min(a.length(), b.length());
+ for (unsigned i = 0; i < minLength; ++i) {
+ if (a[i] == b[i])
+ continue;
+ return a[i] < b[i];
+ }
+ return a.length() < b.length();
}
} } // namespace JSC::DFG
#endif // ENABLE(DFG_JIT)
+namespace WTF {
+
+using namespace JSC::DFG;
+
+void printInternal(PrintStream& out, CapabilityLevel capabilityLevel)
+{
+ switch (capabilityLevel) {
+ case CannotCompile:
+ out.print("CannotCompile");
+ return;
+ case CanCompile:
+ out.print("CanCompile");
+ return;
+ case CanCompileAndInline:
+ out.print("CanCompileAndInline");
+ return;
+ case CapabilityLevelNotSet:
+ out.print("CapabilityLevelNotSet");
+ return;
+ }
+ RELEASE_ASSERT_NOT_REACHED();
+}
+
+} // namespace WTF
+