Commit b1d09b32 authored by erik.corry@gmail.com's avatar erik.corry@gmail.com

Remove dependency on libstdc++ from test framework.

Review URL: http://codereview.chromium.org/99051

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1799 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 22d6cc9d
...@@ -286,6 +286,18 @@ CCTEST_EXTRA_FLAGS = { ...@@ -286,6 +286,18 @@ CCTEST_EXTRA_FLAGS = {
'os:win32': { 'os:win32': {
'LIBS': ['winmm', 'ws2_32'] 'LIBS': ['winmm', 'ws2_32']
}, },
'os:android': {
'CPPDEFINES': ['ANDROID', '__ARM_ARCH_5__', '__ARM_ARCH_5T__',
'__ARM_ARCH_5E__', '__ARM_ARCH_5TE__'],
'CCFLAGS': ANDROID_FLAGS,
'CPPPATH': ANDROID_INCLUDES,
'LIBPATH': [ANDROID_TOP + '/out/target/product/generic/obj/lib'],
'LINKFLAGS': ANDROID_LINKFLAGS,
'LIBS': ['c', 'stdc++', 'm'],
'mode:release': {
'CPPDEFINES': ['SK_RELEASE', 'NDEBUG']
}
},
'wordsize:64': { 'wordsize:64': {
'CCFLAGS': ['-m32'], 'CCFLAGS': ['-m32'],
'LINKFLAGS': ['-m32'] 'LINKFLAGS': ['-m32']
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
// When running without a simulator we call the entry directly. // When running without a simulator we call the entry directly.
#define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \ #define CALL_GENERATED_CODE(entry, p0, p1, p2, p3, p4) \
entry(p0, p1, p2, p3, p4) reinterpret_cast<Object*>(entry(p0, p1, p2, p3, p4))
// Calculated the stack limit beyond which we will throw stack overflow errors. // Calculated the stack limit beyond which we will throw stack overflow errors.
// This macro must be called from a C++ method. It relies on being able to take // This macro must be called from a C++ method. It relies on being able to take
......
...@@ -26,9 +26,6 @@ ...@@ -26,9 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <v8.h> #include <v8.h>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include "cctest.h" #include "cctest.h"
#include "debug.h" #include "debug.h"
......
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <map>
#include <string>
#include "v8.h" #include "v8.h"
#include "api.h" #include "api.h"
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <set>
#include "v8.h" #include "v8.h"
...@@ -499,24 +498,25 @@ const int TestConfig::kNoKey = 0; ...@@ -499,24 +498,25 @@ const int TestConfig::kNoKey = 0;
const int TestConfig::kNoValue = 0; const int TestConfig::kNoValue = 0;
static int PseudoRandom(int i, int j) { static unsigned PseudoRandom(int i, int j) {
return ~(~((i * 781) ^ (j * 329))); return ~(~((i * 781) ^ (j * 329)));
} }
TEST(SplayTreeSimple) { TEST(SplayTreeSimple) {
static const int kLimit = 1000; static const unsigned kLimit = 1000;
ZoneScope zone_scope(DELETE_ON_EXIT); ZoneScope zone_scope(DELETE_ON_EXIT);
ZoneSplayTree<TestConfig> tree; ZoneSplayTree<TestConfig> tree;
std::set<int> seen; bool seen[kLimit];
for (unsigned i = 0; i < kLimit; i++) seen[i] = false;
#define CHECK_MAPS_EQUAL() do { \ #define CHECK_MAPS_EQUAL() do { \
for (int k = 0; k < kLimit; k++) \ for (unsigned k = 0; k < kLimit; k++) \
CHECK_EQ(seen.find(k) != seen.end(), tree.Find(k, &loc)); \ CHECK_EQ(seen[k], tree.Find(k, &loc)); \
} while (false) } while (false)
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
for (int j = 0; j < 50; j++) { for (int j = 0; j < 50; j++) {
int next = PseudoRandom(i, j) % kLimit; unsigned next = PseudoRandom(i, j) % kLimit;
if (seen.find(next) != seen.end()) { if (seen[next]) {
// We've already seen this one. Check the value and remove // We've already seen this one. Check the value and remove
// it. // it.
ZoneSplayTree<TestConfig>::Locator loc; ZoneSplayTree<TestConfig>::Locator loc;
...@@ -524,7 +524,7 @@ TEST(SplayTreeSimple) { ...@@ -524,7 +524,7 @@ TEST(SplayTreeSimple) {
CHECK_EQ(next, loc.key()); CHECK_EQ(next, loc.key());
CHECK_EQ(3 * next, loc.value()); CHECK_EQ(3 * next, loc.value());
tree.Remove(next); tree.Remove(next);
seen.erase(next); seen[next] = false;
CHECK_MAPS_EQUAL(); CHECK_MAPS_EQUAL();
} else { } else {
// Check that it wasn't there already and then add it. // Check that it wasn't there already and then add it.
...@@ -533,26 +533,22 @@ TEST(SplayTreeSimple) { ...@@ -533,26 +533,22 @@ TEST(SplayTreeSimple) {
CHECK(tree.Insert(next, &loc)); CHECK(tree.Insert(next, &loc));
CHECK_EQ(next, loc.key()); CHECK_EQ(next, loc.key());
loc.set_value(3 * next); loc.set_value(3 * next);
seen.insert(next); seen[next] = true;
CHECK_MAPS_EQUAL(); CHECK_MAPS_EQUAL();
} }
int val = PseudoRandom(j, i) % kLimit; int val = PseudoRandom(j, i) % kLimit;
for (int k = val; k >= 0; k--) { if (seen[val]) {
if (seen.find(val) != seen.end()) { ZoneSplayTree<TestConfig>::Locator loc;
ZoneSplayTree<TestConfig>::Locator loc; CHECK(tree.FindGreatestLessThan(val, &loc));
CHECK(tree.FindGreatestLessThan(val, &loc)); CHECK_EQ(loc.key(), val);
CHECK_EQ(loc.key(), val); break;
break;
}
} }
val = PseudoRandom(i + j, i - j) % kLimit; val = PseudoRandom(i + j, i - j) % kLimit;
for (int k = val; k < kLimit; k++) { if (seen[val]) {
if (seen.find(val) != seen.end()) { ZoneSplayTree<TestConfig>::Locator loc;
ZoneSplayTree<TestConfig>::Locator loc; CHECK(tree.FindLeastGreaterThan(val, &loc));
CHECK(tree.FindLeastGreaterThan(val, &loc)); CHECK_EQ(loc.key(), val);
CHECK_EQ(loc.key(), val); break;
break;
}
} }
} }
} }
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <signal.h> #include <signal.h>
#include <map>
#include <string>
#include "sys/stat.h" #include "sys/stat.h"
#include "v8.h" #include "v8.h"
...@@ -42,20 +40,40 @@ ...@@ -42,20 +40,40 @@
using namespace v8::internal; using namespace v8::internal;
static int local_counters[256]; static const unsigned kCounters = 256;
static int counter_count = 0; static int local_counters[kCounters];
static std::map<std::string, int> counter_table; static const char* local_counter_names[kCounters];
static unsigned CounterHash(const char* s) {
unsigned hash = 0;
while (*++s) {
hash |= hash << 5;
hash += *s;
}
return hash;
}
// Callback receiver to track counters in test. // Callback receiver to track counters in test.
static int* counter_function(const char* name) { static int* counter_function(const char* name) {
std::string counter(name); unsigned hash = CounterHash(name) % kCounters;
if (counter_table.find(counter) == counter_table.end()) { unsigned original_hash = hash;
local_counters[counter_count] = 0; USE(original_hash);
counter_table[counter] = counter_count++; while (true) {
if (local_counter_names[hash] == name) {
return &local_counters[hash];
}
if (local_counter_names[hash] == 0) {
local_counter_names[hash] = name;
return &local_counters[hash];
}
if (strcmp(local_counter_names[hash], name) == 0) {
return &local_counters[hash];
}
hash = (hash + 1) % kCounters;
ASSERT(hash != original_hash); // Hash table has been filled up.
} }
return &local_counters[counter_table[counter]];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment