Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: test/cctest/test-serialize.cc

Issue 99051: Remove dependency on libstdc++ from test framework. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <signal.h> 28 #include <signal.h>
29 #include <map>
30 #include <string>
31 29
32 #include "sys/stat.h" 30 #include "sys/stat.h"
33 #include "v8.h" 31 #include "v8.h"
34 32
35 #include "debug.h" 33 #include "debug.h"
36 #include "ic-inl.h" 34 #include "ic-inl.h"
37 #include "runtime.h" 35 #include "runtime.h"
38 #include "serialize.h" 36 #include "serialize.h"
39 #include "scopeinfo.h" 37 #include "scopeinfo.h"
40 #include "snapshot.h" 38 #include "snapshot.h"
41 #include "cctest.h" 39 #include "cctest.h"
42 40
43 using namespace v8::internal; 41 using namespace v8::internal;
44 42
45 static int local_counters[256]; 43 static const unsigned kCounters = 256;
46 static int counter_count = 0; 44 static int local_counters[kCounters];
47 static std::map<std::string, int> counter_table; 45 static const char* local_counter_names[kCounters];
46
47
48 static unsigned CounterHash(const char* s) {
49 unsigned hash = 0;
50 while(*++s) {
51 hash |= hash << 5;
52 hash += *s;
53 }
54 return hash;
55 }
48 56
49 57
50 // Callback receiver to track counters in test. 58 // Callback receiver to track counters in test.
51 static int* counter_function(const char* name) { 59 static int* counter_function(const char* name) {
52 std::string counter(name); 60 unsigned hash = CounterHash(name) % kCounters;
53 if (counter_table.find(counter) == counter_table.end()) { 61 unsigned original_hash = hash;
54 local_counters[counter_count] = 0; 62 USE(original_hash);
55 counter_table[counter] = counter_count++; 63 while(true) {
64 if (local_counter_names[hash] == name) {
65 return &local_counters[hash];
66 }
67 if (local_counter_names[hash] == 0) {
68 local_counter_names[hash] = name;
69 return &local_counters[hash];
70 }
71 if (strcmp(local_counter_names[hash], name) == 0) {
72 return &local_counters[hash];
73 }
74 hash = (hash + 1) % kCounters;
75 ASSERT(hash != original_hash); // Hash table has been filled up.
56 } 76 }
57
58 return &local_counters[counter_table[counter]];
59 } 77 }
60 78
61 79
62 template <class T> 80 template <class T>
63 static Address AddressOf(T id) { 81 static Address AddressOf(T id) {
64 return ExternalReference(id).address(); 82 return ExternalReference(id).address();
65 } 83 }
66 84
67 85
68 template <class T> 86 template <class T>
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 DEPENDENT_TEST(DeserializeExtensions, Serialize) { 277 DEPENDENT_TEST(DeserializeExtensions, Serialize) {
260 v8::HandleScope scope; 278 v8::HandleScope scope;
261 279
262 Deserialize(); 280 Deserialize();
263 const char* c_source = "gc();"; 281 const char* c_source = "gc();";
264 v8::Local<v8::String> source = v8::String::New(c_source); 282 v8::Local<v8::String> source = v8::String::New(c_source);
265 v8::Local<v8::Script> script = v8::Script::Compile(source); 283 v8::Local<v8::Script> script = v8::Script::Compile(source);
266 v8::Local<v8::Value> value = script->Run(); 284 v8::Local<v8::Value> value = script->Run();
267 CHECK(value->IsUndefined()); 285 CHECK(value->IsUndefined());
268 } 286 }
OLDNEW
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | tools/test.py » ('j') | tools/test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698