Author: [email protected]
Date: Mon Apr 27 03:52:44 2009
New Revision: 1799

Modified:
    branches/bleeding_edge/SConstruct
    branches/bleeding_edge/src/arm/simulator-arm.h
    branches/bleeding_edge/test/cctest/cctest.cc
    branches/bleeding_edge/test/cctest/test-api.cc
    branches/bleeding_edge/test/cctest/test-regexp.cc
    branches/bleeding_edge/test/cctest/test-serialize.cc

Log:
Remove dependency on libstdc++ from test framework.
Review URL: http://codereview.chromium.org/99051

Modified: branches/bleeding_edge/SConstruct
==============================================================================
--- branches/bleeding_edge/SConstruct   (original)
+++ branches/bleeding_edge/SConstruct   Mon Apr 27 03:52:44 2009
@@ -286,6 +286,18 @@
      'os:win32': {
        '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': {
        'CCFLAGS':      ['-m32'],
        'LINKFLAGS':    ['-m32']

Modified: branches/bleeding_edge/src/arm/simulator-arm.h
==============================================================================
--- branches/bleeding_edge/src/arm/simulator-arm.h      (original)
+++ branches/bleeding_edge/src/arm/simulator-arm.h      Mon Apr 27 03:52:44 2009
@@ -40,7 +40,7 @@

  // When running without a simulator we call the entry directly.
  #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.
  // This macro must be called from a C++ method. It relies on being able to  
take

Modified: branches/bleeding_edge/test/cctest/cctest.cc
==============================================================================
--- branches/bleeding_edge/test/cctest/cctest.cc        (original)
+++ branches/bleeding_edge/test/cctest/cctest.cc        Mon Apr 27 03:52:44 2009
@@ -26,9 +26,6 @@
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

  #include <v8.h>
-#include <cstdlib>
-#include <cstring>
-#include <cstdio>
  #include "cctest.h"
  #include "debug.h"


Modified: branches/bleeding_edge/test/cctest/test-api.cc
==============================================================================
--- branches/bleeding_edge/test/cctest/test-api.cc      (original)
+++ branches/bleeding_edge/test/cctest/test-api.cc      Mon Apr 27 03:52:44 2009
@@ -27,9 +27,6 @@

  #include <stdlib.h>

-#include <map>
-#include <string>
-
  #include "v8.h"

  #include "api.h"

Modified: branches/bleeding_edge/test/cctest/test-regexp.cc
==============================================================================
--- branches/bleeding_edge/test/cctest/test-regexp.cc   (original)
+++ branches/bleeding_edge/test/cctest/test-regexp.cc   Mon Apr 27 03:52:44  
2009
@@ -27,7 +27,6 @@


  #include <stdlib.h>
-#include <set>

  #include "v8.h"

@@ -499,24 +498,25 @@
  const int TestConfig::kNoValue = 0;


-static int PseudoRandom(int i, int j) {
+static unsigned PseudoRandom(int i, int j) {
    return ~(~((i * 781) ^ (j * 329)));
  }


  TEST(SplayTreeSimple) {
-  static const int kLimit = 1000;
+  static const unsigned kLimit = 1000;
    ZoneScope zone_scope(DELETE_ON_EXIT);
    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 {                                      \
-    for (int k = 0; k < kLimit; k++)                                 \
-      CHECK_EQ(seen.find(k) != seen.end(), tree.Find(k, &loc));      \
+    for (unsigned k = 0; k < kLimit; k++)                            \
+      CHECK_EQ(seen[k], tree.Find(k, &loc));                         \
    } while (false)
    for (int i = 0; i < 50; i++) {
      for (int j = 0; j < 50; j++) {
-      int next = PseudoRandom(i, j) % kLimit;
-      if (seen.find(next) != seen.end()) {
+      unsigned next = PseudoRandom(i, j) % kLimit;
+      if (seen[next]) {
          // We've already seen this one.  Check the value and remove
          // it.
          ZoneSplayTree<TestConfig>::Locator loc;
@@ -524,7 +524,7 @@
          CHECK_EQ(next, loc.key());
          CHECK_EQ(3 * next, loc.value());
          tree.Remove(next);
-        seen.erase(next);
+        seen[next] = false;
          CHECK_MAPS_EQUAL();
        } else {
          // Check that it wasn't there already and then add it.
@@ -533,26 +533,22 @@
          CHECK(tree.Insert(next, &loc));
          CHECK_EQ(next, loc.key());
          loc.set_value(3 * next);
-        seen.insert(next);
+        seen[next] = true;
          CHECK_MAPS_EQUAL();
        }
        int val = PseudoRandom(j, i) % kLimit;
-      for (int k = val; k >= 0; k--) {
-        if (seen.find(val) != seen.end()) {
-          ZoneSplayTree<TestConfig>::Locator loc;
-          CHECK(tree.FindGreatestLessThan(val, &loc));
-          CHECK_EQ(loc.key(), val);
-          break;
-        }
+      if (seen[val]) {
+        ZoneSplayTree<TestConfig>::Locator loc;
+        CHECK(tree.FindGreatestLessThan(val, &loc));
+        CHECK_EQ(loc.key(), val);
+        break;
        }
        val = PseudoRandom(i + j, i - j) % kLimit;
-      for (int k = val; k < kLimit; k++) {
-        if (seen.find(val) != seen.end()) {
-          ZoneSplayTree<TestConfig>::Locator loc;
-          CHECK(tree.FindLeastGreaterThan(val, &loc));
-          CHECK_EQ(loc.key(), val);
-          break;
-        }
+      if (seen[val]) {
+        ZoneSplayTree<TestConfig>::Locator loc;
+        CHECK(tree.FindLeastGreaterThan(val, &loc));
+        CHECK_EQ(loc.key(), val);
+        break;
        }
      }
    }

Modified: branches/bleeding_edge/test/cctest/test-serialize.cc
==============================================================================
--- branches/bleeding_edge/test/cctest/test-serialize.cc        (original)
+++ branches/bleeding_edge/test/cctest/test-serialize.cc        Mon Apr 27  
03:52:44 2009
@@ -26,8 +26,6 @@
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

  #include <signal.h>
-#include <map>
-#include <string>

  #include "sys/stat.h"
  #include "v8.h"
@@ -42,20 +40,40 @@

  using namespace v8::internal;

-static int local_counters[256];
-static int counter_count = 0;
-static std::map<std::string, int> counter_table;
+static const unsigned kCounters = 256;
+static int local_counters[kCounters];
+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.
  static int* counter_function(const char* name) {
-  std::string counter(name);
-  if (counter_table.find(counter) == counter_table.end()) {
-    local_counters[counter_count] = 0;
-    counter_table[counter] = counter_count++;
+  unsigned hash = CounterHash(name) % kCounters;
+  unsigned original_hash = hash;
+  USE(original_hash);
+  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]];
  }



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to