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

Side by Side Diff: test/cctest/test-feedback-vector.cc

Issue 1154103005: Refactor lexical home object binding (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git rebase Created 5 years, 6 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
« no previous file with comments | « test/cctest/test-compiler.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 #include "test/cctest/cctest.h" 6 #include "test/cctest/cctest.h"
7 7
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/debug.h" 9 #include "src/debug.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 166 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
167 // There should be one IC. 167 // There should be one IC.
168 Handle<Code> code = handle(f->shared()->code(), isolate); 168 Handle<Code> code = handle(f->shared()->code(), isolate);
169 TypeFeedbackInfo* feedback_info = 169 TypeFeedbackInfo* feedback_info =
170 TypeFeedbackInfo::cast(code->type_feedback_info()); 170 TypeFeedbackInfo::cast(code->type_feedback_info());
171 CHECK_EQ(1, feedback_info->ic_total_count()); 171 CHECK_EQ(1, feedback_info->ic_total_count());
172 CHECK_EQ(0, feedback_info->ic_with_type_info_count()); 172 CHECK_EQ(0, feedback_info->ic_with_type_info_count());
173 CHECK_EQ(0, feedback_info->ic_generic_count()); 173 CHECK_EQ(0, feedback_info->ic_generic_count());
174 Handle<TypeFeedbackVector> feedback_vector = 174 Handle<TypeFeedbackVector> feedback_vector =
175 handle(f->shared()->feedback_vector(), isolate); 175 handle(f->shared()->feedback_vector(), isolate);
176 int ic_slot = 1; 176 int ic_slot = 0;
177 CallICNexus nexus(feedback_vector, FeedbackVectorICSlot(ic_slot)); 177 CallICNexus nexus(feedback_vector, FeedbackVectorICSlot(ic_slot));
178 CHECK_EQ(1, feedback_vector->ic_with_type_info_count()); 178 CHECK_EQ(1, feedback_vector->ic_with_type_info_count());
179 CHECK_EQ(0, feedback_vector->ic_generic_count()); 179 CHECK_EQ(0, feedback_vector->ic_generic_count());
180 180
181 // Now send the information generic. 181 // Now send the information generic.
182 CompileRun("f(Object);"); 182 CompileRun("f(Object);");
183 CHECK_EQ(0, feedback_vector->ic_with_type_info_count()); 183 CHECK_EQ(0, feedback_vector->ic_with_type_info_count());
184 CHECK_EQ(1, feedback_vector->ic_generic_count()); 184 CHECK_EQ(1, feedback_vector->ic_generic_count());
185 185
186 // A collection will not affect the site. 186 // A collection will not affect the site.
(...skipping 28 matching lines...) Expand all
215 215
216 // Make sure function f has a call that uses a type feedback slot. 216 // Make sure function f has a call that uses a type feedback slot.
217 CompileRun( 217 CompileRun(
218 "function foo() { return 17; }" 218 "function foo() { return 17; }"
219 "function f(a) { a(); } f(foo);"); 219 "function f(a) { a(); } f(foo);");
220 Handle<JSFunction> f = v8::Utils::OpenHandle( 220 Handle<JSFunction> f = v8::Utils::OpenHandle(
221 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 221 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
222 // There should be one IC. 222 // There should be one IC.
223 Handle<TypeFeedbackVector> feedback_vector = 223 Handle<TypeFeedbackVector> feedback_vector =
224 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate); 224 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate);
225 FeedbackVectorICSlot slot(1); 225 FeedbackVectorICSlot slot(0);
226 CallICNexus nexus(feedback_vector, slot); 226 CallICNexus nexus(feedback_vector, slot);
227 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 227 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
228 // CallIC doesn't return map feedback. 228 // CallIC doesn't return map feedback.
229 CHECK(!nexus.FindFirstMap()); 229 CHECK(!nexus.FindFirstMap());
230 230
231 CompileRun("f(function() { return 16; })"); 231 CompileRun("f(function() { return 16; })");
232 CHECK_EQ(GENERIC, nexus.StateFromFeedback()); 232 CHECK_EQ(GENERIC, nexus.StateFromFeedback());
233 233
234 // After a collection, state should remain GENERIC. 234 // After a collection, state should remain GENERIC.
235 heap->CollectAllGarbage(); 235 heap->CollectAllGarbage();
(...skipping 21 matching lines...) Expand all
257 257
258 // Make sure function f has a call that uses a type feedback slot. 258 // Make sure function f has a call that uses a type feedback slot.
259 CompileRun( 259 CompileRun(
260 "var o = { foo: 3 };" 260 "var o = { foo: 3 };"
261 "function f(a) { return a.foo; } f(o);"); 261 "function f(a) { return a.foo; } f(o);");
262 Handle<JSFunction> f = v8::Utils::OpenHandle( 262 Handle<JSFunction> f = v8::Utils::OpenHandle(
263 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 263 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
264 // There should be one IC. 264 // There should be one IC.
265 Handle<TypeFeedbackVector> feedback_vector = 265 Handle<TypeFeedbackVector> feedback_vector =
266 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate); 266 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate);
267 FeedbackVectorICSlot slot(1); 267 FeedbackVectorICSlot slot(0);
268 LoadICNexus nexus(feedback_vector, slot); 268 LoadICNexus nexus(feedback_vector, slot);
269 CHECK_EQ(PREMONOMORPHIC, nexus.StateFromFeedback()); 269 CHECK_EQ(PREMONOMORPHIC, nexus.StateFromFeedback());
270 270
271 CompileRun("f(o)"); 271 CompileRun("f(o)");
272 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 272 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
273 // Verify that the monomorphic map is the one we expect. 273 // Verify that the monomorphic map is the one we expect.
274 Handle<JSObject> o = v8::Utils::OpenHandle( 274 Handle<JSObject> o = v8::Utils::OpenHandle(
275 *v8::Handle<v8::Object>::Cast(CcTest::global()->Get(v8_str("o")))); 275 *v8::Handle<v8::Object>::Cast(CcTest::global()->Get(v8_str("o"))));
276 CHECK_EQ(o->map(), nexus.FindFirstMap()); 276 CHECK_EQ(o->map(), nexus.FindFirstMap());
277 277
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 "function f() {" 315 "function f() {"
316 " var x = o + 10;" 316 " var x = o + 10;"
317 " return o + x + o;" 317 " return o + x + o;"
318 "}" 318 "}"
319 "f();"); 319 "f();");
320 Handle<JSFunction> f = v8::Utils::OpenHandle( 320 Handle<JSFunction> f = v8::Utils::OpenHandle(
321 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 321 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
322 // There should be one IC slot. 322 // There should be one IC slot.
323 Handle<TypeFeedbackVector> feedback_vector = 323 Handle<TypeFeedbackVector> feedback_vector =
324 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate); 324 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate);
325 CHECK_EQ(2, feedback_vector->ICSlots()); 325 CHECK_EQ(1, feedback_vector->ICSlots());
326 FeedbackVectorICSlot slot(1); 326 FeedbackVectorICSlot slot(0);
327 LoadICNexus nexus(feedback_vector, slot); 327 LoadICNexus nexus(feedback_vector, slot);
328 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 328 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
329 } 329 }
330 330
331 331
332 TEST(VectorLoadICOnSmi) { 332 TEST(VectorLoadICOnSmi) {
333 if (i::FLAG_always_opt) return; 333 if (i::FLAG_always_opt) return;
334 CcTest::InitializeVM(); 334 CcTest::InitializeVM();
335 LocalContext context; 335 LocalContext context;
336 v8::HandleScope scope(context->GetIsolate()); 336 v8::HandleScope scope(context->GetIsolate());
337 Isolate* isolate = CcTest::i_isolate(); 337 Isolate* isolate = CcTest::i_isolate();
338 Heap* heap = isolate->heap(); 338 Heap* heap = isolate->heap();
339 339
340 // Make sure function f has a call that uses a type feedback slot. 340 // Make sure function f has a call that uses a type feedback slot.
341 CompileRun( 341 CompileRun(
342 "var o = { foo: 3 };" 342 "var o = { foo: 3 };"
343 "function f(a) { return a.foo; } f(o);"); 343 "function f(a) { return a.foo; } f(o);");
344 Handle<JSFunction> f = v8::Utils::OpenHandle( 344 Handle<JSFunction> f = v8::Utils::OpenHandle(
345 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 345 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
346 // There should be one IC. 346 // There should be one IC.
347 Handle<TypeFeedbackVector> feedback_vector = 347 Handle<TypeFeedbackVector> feedback_vector =
348 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate); 348 Handle<TypeFeedbackVector>(f->shared()->feedback_vector(), isolate);
349 FeedbackVectorICSlot slot(1); 349 FeedbackVectorICSlot slot(0);
350 LoadICNexus nexus(feedback_vector, slot); 350 LoadICNexus nexus(feedback_vector, slot);
351 CHECK_EQ(PREMONOMORPHIC, nexus.StateFromFeedback()); 351 CHECK_EQ(PREMONOMORPHIC, nexus.StateFromFeedback());
352 352
353 CompileRun("f(34)"); 353 CompileRun("f(34)");
354 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback()); 354 CHECK_EQ(MONOMORPHIC, nexus.StateFromFeedback());
355 // Verify that the monomorphic map is the one we expect. 355 // Verify that the monomorphic map is the one we expect.
356 Map* number_map = heap->heap_number_map(); 356 Map* number_map = heap->heap_number_map();
357 CHECK_EQ(number_map, nexus.FindFirstMap()); 357 CHECK_EQ(number_map, nexus.FindFirstMap());
358 358
359 // Now go polymorphic on o. 359 // Now go polymorphic on o.
(...skipping 19 matching lines...) Expand all
379 CHECK(number_map_found && o_map_found); 379 CHECK(number_map_found && o_map_found);
380 380
381 // The degree of polymorphism doesn't change. 381 // The degree of polymorphism doesn't change.
382 CompileRun("f(100)"); 382 CompileRun("f(100)");
383 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback()); 383 CHECK_EQ(POLYMORPHIC, nexus.StateFromFeedback());
384 MapHandleList maps2; 384 MapHandleList maps2;
385 nexus.FindAllMaps(&maps2); 385 nexus.FindAllMaps(&maps2);
386 CHECK_EQ(2, maps2.length()); 386 CHECK_EQ(2, maps2.length());
387 } 387 }
388 } 388 }
OLDNEW
« no previous file with comments | « test/cctest/test-compiler.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698