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

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

Issue 6713074: Require an isolate parameter for most external reference creation to (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Further cleanup Created 9 years, 9 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
« no previous file with comments | « test/cctest/test-disasm-ia32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. 1 // Copyright 2007-2010 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
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return &local_counters[hash]; 76 return &local_counters[hash];
77 } 77 }
78 hash = (hash + 1) % kCounters; 78 hash = (hash + 1) % kCounters;
79 ASSERT(hash != original_hash); // Hash table has been filled up. 79 ASSERT(hash != original_hash); // Hash table has been filled up.
80 } 80 }
81 } 81 }
82 82
83 83
84 template <class T> 84 template <class T>
85 static Address AddressOf(T id) { 85 static Address AddressOf(T id) {
86 return ExternalReference(id).address(); 86 return ExternalReference(id, i::Isolate::Current()).address();
87 } 87 }
88 88
89 89
90 template <class T> 90 template <class T>
91 static uint32_t Encode(const ExternalReferenceEncoder& encoder, T id) { 91 static uint32_t Encode(const ExternalReferenceEncoder& encoder, T id) {
92 return encoder.Encode(AddressOf(id)); 92 return encoder.Encode(AddressOf(id));
93 } 93 }
94 94
95 95
96 static int make_code(TypeCode type, int id) { 96 static int make_code(TypeCode type, int id) {
97 return static_cast<uint32_t>(type) << kReferenceTypeShift | id; 97 return static_cast<uint32_t>(type) << kReferenceTypeShift | id;
98 } 98 }
99 99
100 100
101 TEST(ExternalReferenceEncoder) { 101 TEST(ExternalReferenceEncoder) {
102 OS::Setup(); 102 OS::Setup();
103 i::Isolate::Current()->stats_table()->SetCounterFunction(counter_function); 103 Isolate* isolate = i::Isolate::Current();
104 isolate->stats_table()->SetCounterFunction(counter_function);
104 HEAP->Setup(false); 105 HEAP->Setup(false);
105 ExternalReferenceEncoder encoder; 106 ExternalReferenceEncoder encoder;
106 CHECK_EQ(make_code(BUILTIN, Builtins::ArrayCode), 107 CHECK_EQ(make_code(BUILTIN, Builtins::ArrayCode),
107 Encode(encoder, Builtins::ArrayCode)); 108 Encode(encoder, Builtins::ArrayCode));
108 CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort), 109 CHECK_EQ(make_code(v8::internal::RUNTIME_FUNCTION, Runtime::kAbort),
109 Encode(encoder, Runtime::kAbort)); 110 Encode(encoder, Runtime::kAbort));
110 CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty), 111 CHECK_EQ(make_code(IC_UTILITY, IC::kLoadCallbackProperty),
111 Encode(encoder, IC_Utility(IC::kLoadCallbackProperty))); 112 Encode(encoder, IC_Utility(IC::kLoadCallbackProperty)));
112 ExternalReference keyed_load_function_prototype = 113 ExternalReference keyed_load_function_prototype =
113 ExternalReference(COUNTERS->keyed_load_function_prototype()); 114 ExternalReference(COUNTERS->keyed_load_function_prototype());
114 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype), 115 CHECK_EQ(make_code(STATS_COUNTER, Counters::k_keyed_load_function_prototype),
115 encoder.Encode(keyed_load_function_prototype.address())); 116 encoder.Encode(keyed_load_function_prototype.address()));
116 ExternalReference the_hole_value_location = 117 ExternalReference the_hole_value_location =
117 ExternalReference::the_hole_value_location(); 118 ExternalReference::the_hole_value_location(isolate);
118 CHECK_EQ(make_code(UNCLASSIFIED, 2), 119 CHECK_EQ(make_code(UNCLASSIFIED, 2),
119 encoder.Encode(the_hole_value_location.address())); 120 encoder.Encode(the_hole_value_location.address()));
120 ExternalReference stack_limit_address = 121 ExternalReference stack_limit_address =
121 ExternalReference::address_of_stack_limit(); 122 ExternalReference::address_of_stack_limit(isolate);
122 CHECK_EQ(make_code(UNCLASSIFIED, 4), 123 CHECK_EQ(make_code(UNCLASSIFIED, 4),
123 encoder.Encode(stack_limit_address.address())); 124 encoder.Encode(stack_limit_address.address()));
124 ExternalReference real_stack_limit_address = 125 ExternalReference real_stack_limit_address =
125 ExternalReference::address_of_real_stack_limit(); 126 ExternalReference::address_of_real_stack_limit(isolate);
126 CHECK_EQ(make_code(UNCLASSIFIED, 5), 127 CHECK_EQ(make_code(UNCLASSIFIED, 5),
127 encoder.Encode(real_stack_limit_address.address())); 128 encoder.Encode(real_stack_limit_address.address()));
128 #ifdef ENABLE_DEBUGGER_SUPPORT 129 #ifdef ENABLE_DEBUGGER_SUPPORT
129 CHECK_EQ(make_code(UNCLASSIFIED, 15), 130 CHECK_EQ(make_code(UNCLASSIFIED, 15),
130 encoder.Encode(ExternalReference::debug_break().address())); 131 encoder.Encode(ExternalReference::debug_break(isolate).address()));
131 #endif // ENABLE_DEBUGGER_SUPPORT 132 #endif // ENABLE_DEBUGGER_SUPPORT
132 CHECK_EQ(make_code(UNCLASSIFIED, 10), 133 CHECK_EQ(make_code(UNCLASSIFIED, 10),
133 encoder.Encode(ExternalReference::new_space_start().address())); 134 encoder.Encode(
135 ExternalReference::new_space_start(isolate).address()));
134 CHECK_EQ(make_code(UNCLASSIFIED, 3), 136 CHECK_EQ(make_code(UNCLASSIFIED, 3),
135 encoder.Encode(ExternalReference::roots_address().address())); 137 encoder.Encode(ExternalReference::roots_address(isolate).address()));
136 } 138 }
137 139
138 140
139 TEST(ExternalReferenceDecoder) { 141 TEST(ExternalReferenceDecoder) {
140 OS::Setup(); 142 OS::Setup();
141 i::Isolate::Current()->stats_table()->SetCounterFunction(counter_function); 143 Isolate* isolate = i::Isolate::Current();
144 isolate->stats_table()->SetCounterFunction(counter_function);
142 HEAP->Setup(false); 145 HEAP->Setup(false);
143 ExternalReferenceDecoder decoder; 146 ExternalReferenceDecoder decoder;
144 CHECK_EQ(AddressOf(Builtins::ArrayCode), 147 CHECK_EQ(AddressOf(Builtins::ArrayCode),
145 decoder.Decode(make_code(BUILTIN, Builtins::ArrayCode))); 148 decoder.Decode(make_code(BUILTIN, Builtins::ArrayCode)));
146 CHECK_EQ(AddressOf(Runtime::kAbort), 149 CHECK_EQ(AddressOf(Runtime::kAbort),
147 decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION, 150 decoder.Decode(make_code(v8::internal::RUNTIME_FUNCTION,
148 Runtime::kAbort))); 151 Runtime::kAbort)));
149 CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)), 152 CHECK_EQ(AddressOf(IC_Utility(IC::kLoadCallbackProperty)),
150 decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty))); 153 decoder.Decode(make_code(IC_UTILITY, IC::kLoadCallbackProperty)));
151 ExternalReference keyed_load_function = 154 ExternalReference keyed_load_function =
152 ExternalReference(COUNTERS->keyed_load_function_prototype()); 155 ExternalReference(COUNTERS->keyed_load_function_prototype());
153 CHECK_EQ(keyed_load_function.address(), 156 CHECK_EQ(keyed_load_function.address(),
154 decoder.Decode( 157 decoder.Decode(
155 make_code(STATS_COUNTER, 158 make_code(STATS_COUNTER,
156 Counters::k_keyed_load_function_prototype))); 159 Counters::k_keyed_load_function_prototype)));
157 CHECK_EQ(ExternalReference::the_hole_value_location().address(), 160 CHECK_EQ(ExternalReference::the_hole_value_location(isolate).address(),
158 decoder.Decode(make_code(UNCLASSIFIED, 2))); 161 decoder.Decode(make_code(UNCLASSIFIED, 2)));
159 CHECK_EQ(ExternalReference::address_of_stack_limit().address(), 162 CHECK_EQ(ExternalReference::address_of_stack_limit(isolate).address(),
160 decoder.Decode(make_code(UNCLASSIFIED, 4))); 163 decoder.Decode(make_code(UNCLASSIFIED, 4)));
161 CHECK_EQ(ExternalReference::address_of_real_stack_limit().address(), 164 CHECK_EQ(ExternalReference::address_of_real_stack_limit(isolate).address(),
162 decoder.Decode(make_code(UNCLASSIFIED, 5))); 165 decoder.Decode(make_code(UNCLASSIFIED, 5)));
163 #ifdef ENABLE_DEBUGGER_SUPPORT 166 #ifdef ENABLE_DEBUGGER_SUPPORT
164 CHECK_EQ(ExternalReference::debug_break().address(), 167 CHECK_EQ(ExternalReference::debug_break(isolate).address(),
165 decoder.Decode(make_code(UNCLASSIFIED, 15))); 168 decoder.Decode(make_code(UNCLASSIFIED, 15)));
166 #endif // ENABLE_DEBUGGER_SUPPORT 169 #endif // ENABLE_DEBUGGER_SUPPORT
167 CHECK_EQ(ExternalReference::new_space_start().address(), 170 CHECK_EQ(ExternalReference::new_space_start(isolate).address(),
168 decoder.Decode(make_code(UNCLASSIFIED, 10))); 171 decoder.Decode(make_code(UNCLASSIFIED, 10)));
169 } 172 }
170 173
171 174
172 class FileByteSink : public SnapshotByteSink { 175 class FileByteSink : public SnapshotByteSink {
173 public: 176 public:
174 explicit FileByteSink(const char* snapshot_file) { 177 explicit FileByteSink(const char* snapshot_file) {
175 fp_ = OS::FOpen(snapshot_file, "wb"); 178 fp_ = OS::FOpen(snapshot_file, "wb");
176 file_name_ = snapshot_file; 179 file_name_ = snapshot_file;
177 if (fp_ == NULL) { 180 if (fp_ == NULL) {
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 TEST(TestThatAlwaysFails) { 670 TEST(TestThatAlwaysFails) {
668 bool ArtificialFailure = false; 671 bool ArtificialFailure = false;
669 CHECK(ArtificialFailure); 672 CHECK(ArtificialFailure);
670 } 673 }
671 674
672 675
673 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { 676 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
674 bool ArtificialFailure2 = false; 677 bool ArtificialFailure2 = false;
675 CHECK(ArtificialFailure2); 678 CHECK(ArtificialFailure2);
676 } 679 }
OLDNEW
« no previous file with comments | « test/cctest/test-disasm-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698