OLD | NEW |
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 #ifndef V8_TYPE_FEEDBACK_VECTOR_H_ | 5 #ifndef V8_TYPE_FEEDBACK_VECTOR_H_ |
6 #define V8_TYPE_FEEDBACK_VECTOR_H_ | 6 #define V8_TYPE_FEEDBACK_VECTOR_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "src/checks.h" | 10 #include "src/checks.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 287 |
288 // TODO(mvstanton): remove FindAllMaps, it didn't survive a code review. | 288 // TODO(mvstanton): remove FindAllMaps, it didn't survive a code review. |
289 void FindAllMaps(MapHandleList* maps) const { ExtractMaps(maps); } | 289 void FindAllMaps(MapHandleList* maps) const { ExtractMaps(maps); } |
290 | 290 |
291 virtual InlineCacheState StateFromFeedback() const = 0; | 291 virtual InlineCacheState StateFromFeedback() const = 0; |
292 virtual int ExtractMaps(MapHandleList* maps) const; | 292 virtual int ExtractMaps(MapHandleList* maps) const; |
293 virtual MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const; | 293 virtual MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const; |
294 virtual bool FindHandlers(CodeHandleList* code_list, int length = -1) const; | 294 virtual bool FindHandlers(CodeHandleList* code_list, int length = -1) const; |
295 virtual Name* FindFirstName() const { return NULL; } | 295 virtual Name* FindFirstName() const { return NULL; } |
296 | 296 |
| 297 virtual void ConfigureUninitialized(); |
| 298 virtual void ConfigurePremonomorphic(); |
| 299 virtual void ConfigureMegamorphic(); |
| 300 |
297 Object* GetFeedback() const { return vector()->Get(slot()); } | 301 Object* GetFeedback() const { return vector()->Get(slot()); } |
298 Object* GetFeedbackExtra() const { | 302 Object* GetFeedbackExtra() const { |
299 DCHECK(TypeFeedbackVector::elements_per_ic_slot() > 1); | 303 DCHECK(TypeFeedbackVector::elements_per_ic_slot() > 1); |
300 int extra_index = vector()->GetIndex(slot()) + 1; | 304 int extra_index = vector()->GetIndex(slot()) + 1; |
301 return vector()->get(extra_index); | 305 return vector()->get(extra_index); |
302 } | 306 } |
303 | 307 |
304 protected: | 308 protected: |
305 Isolate* GetIsolate() const { return vector()->GetIsolate(); } | 309 Isolate* GetIsolate() const { return vector()->GetIsolate(); } |
306 | 310 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 : FeedbackNexus(vector, slot) { | 346 : FeedbackNexus(vector, slot) { |
343 DCHECK(vector->GetKind(slot) == Code::CALL_IC); | 347 DCHECK(vector->GetKind(slot) == Code::CALL_IC); |
344 } | 348 } |
345 CallICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot) | 349 CallICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot) |
346 : FeedbackNexus(vector, slot) { | 350 : FeedbackNexus(vector, slot) { |
347 DCHECK(vector->GetKind(slot) == Code::CALL_IC); | 351 DCHECK(vector->GetKind(slot) == Code::CALL_IC); |
348 } | 352 } |
349 | 353 |
350 void Clear(Code* host); | 354 void Clear(Code* host); |
351 | 355 |
352 void ConfigureUninitialized(); | |
353 void ConfigureGeneric(); | |
354 void ConfigureMonomorphicArray(); | 356 void ConfigureMonomorphicArray(); |
355 void ConfigureMonomorphic(Handle<JSFunction> function); | 357 void ConfigureMonomorphic(Handle<JSFunction> function); |
356 | 358 |
357 InlineCacheState StateFromFeedback() const override; | 359 InlineCacheState StateFromFeedback() const override; |
358 | 360 |
359 int ExtractMaps(MapHandleList* maps) const override { | 361 int ExtractMaps(MapHandleList* maps) const override { |
360 // CallICs don't record map feedback. | 362 // CallICs don't record map feedback. |
361 return 0; | 363 return 0; |
362 } | 364 } |
363 MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const override { | 365 MaybeHandle<Code> FindHandlerForMap(Handle<Map> map) const override { |
364 return MaybeHandle<Code>(); | 366 return MaybeHandle<Code>(); |
365 } | 367 } |
366 virtual bool FindHandlers(CodeHandleList* code_list, | 368 bool FindHandlers(CodeHandleList* code_list, int length = -1) const override { |
367 int length = -1) const override { | |
368 return length == 0; | 369 return length == 0; |
369 } | 370 } |
370 | 371 |
371 int ExtractCallCount(); | 372 int ExtractCallCount(); |
372 }; | 373 }; |
373 | 374 |
374 | 375 |
375 class LoadICNexus : public FeedbackNexus { | 376 class LoadICNexus : public FeedbackNexus { |
376 public: | 377 public: |
377 LoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot) | 378 LoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot) |
378 : FeedbackNexus(vector, slot) { | 379 : FeedbackNexus(vector, slot) { |
379 DCHECK(vector->GetKind(slot) == Code::LOAD_IC); | 380 DCHECK(vector->GetKind(slot) == Code::LOAD_IC); |
380 } | 381 } |
381 LoadICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot) | 382 LoadICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot) |
382 : FeedbackNexus(vector, slot) { | 383 : FeedbackNexus(vector, slot) { |
383 DCHECK(vector->GetKind(slot) == Code::LOAD_IC); | 384 DCHECK(vector->GetKind(slot) == Code::LOAD_IC); |
384 } | 385 } |
385 | 386 |
386 void Clear(Code* host); | 387 void Clear(Code* host); |
387 | 388 |
388 void ConfigureMegamorphic(); | |
389 void ConfigurePremonomorphic(); | |
390 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Code> handler); | 389 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Code> handler); |
391 | 390 |
392 void ConfigurePolymorphic(MapHandleList* maps, CodeHandleList* handlers); | 391 void ConfigurePolymorphic(MapHandleList* maps, CodeHandleList* handlers); |
393 | 392 |
394 InlineCacheState StateFromFeedback() const override; | 393 InlineCacheState StateFromFeedback() const override; |
395 }; | 394 }; |
396 | 395 |
397 | 396 |
398 class KeyedLoadICNexus : public FeedbackNexus { | 397 class KeyedLoadICNexus : public FeedbackNexus { |
399 public: | 398 public: |
400 KeyedLoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot) | 399 KeyedLoadICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot) |
401 : FeedbackNexus(vector, slot) { | 400 : FeedbackNexus(vector, slot) { |
402 DCHECK(vector->GetKind(slot) == Code::KEYED_LOAD_IC); | 401 DCHECK(vector->GetKind(slot) == Code::KEYED_LOAD_IC); |
403 } | 402 } |
404 KeyedLoadICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot) | 403 KeyedLoadICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot) |
405 : FeedbackNexus(vector, slot) { | 404 : FeedbackNexus(vector, slot) { |
406 DCHECK(vector->GetKind(slot) == Code::KEYED_LOAD_IC); | 405 DCHECK(vector->GetKind(slot) == Code::KEYED_LOAD_IC); |
407 } | 406 } |
408 | 407 |
409 void Clear(Code* host); | 408 void Clear(Code* host); |
410 | 409 |
411 void ConfigureMegamorphic(); | |
412 void ConfigurePremonomorphic(); | |
413 // name can be a null handle for element loads. | 410 // name can be a null handle for element loads. |
414 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, | 411 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, |
415 Handle<Code> handler); | 412 Handle<Code> handler); |
| 413 // name can be null. |
| 414 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, |
| 415 CodeHandleList* handlers); |
| 416 |
| 417 InlineCacheState StateFromFeedback() const override; |
| 418 Name* FindFirstName() const override; |
| 419 }; |
| 420 |
| 421 |
| 422 class StoreICNexus : public FeedbackNexus { |
| 423 public: |
| 424 StoreICNexus(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot) |
| 425 : FeedbackNexus(vector, slot) { |
| 426 DCHECK(vector->GetKind(slot) == Code::STORE_IC); |
| 427 } |
| 428 StoreICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot) |
| 429 : FeedbackNexus(vector, slot) { |
| 430 DCHECK(vector->GetKind(slot) == Code::STORE_IC); |
| 431 } |
| 432 |
| 433 void Clear(Code* host); |
| 434 |
| 435 void ConfigureMonomorphic(Handle<Map> receiver_map, Handle<Code> handler); |
| 436 |
| 437 void ConfigurePolymorphic(MapHandleList* maps, CodeHandleList* handlers); |
| 438 |
| 439 InlineCacheState StateFromFeedback() const override; |
| 440 }; |
| 441 |
| 442 |
| 443 class KeyedStoreICNexus : public FeedbackNexus { |
| 444 public: |
| 445 KeyedStoreICNexus(Handle<TypeFeedbackVector> vector, |
| 446 FeedbackVectorICSlot slot) |
| 447 : FeedbackNexus(vector, slot) { |
| 448 DCHECK(vector->GetKind(slot) == Code::KEYED_STORE_IC); |
| 449 } |
| 450 KeyedStoreICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot) |
| 451 : FeedbackNexus(vector, slot) { |
| 452 DCHECK(vector->GetKind(slot) == Code::KEYED_STORE_IC); |
| 453 } |
| 454 |
| 455 void Clear(Code* host); |
| 456 |
| 457 // name can be a null handle for element loads. |
| 458 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, |
| 459 Handle<Code> handler); |
416 // name can be null. | 460 // name can be null. |
417 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, | 461 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, |
418 CodeHandleList* handlers); | 462 CodeHandleList* handlers); |
419 | 463 |
420 InlineCacheState StateFromFeedback() const override; | 464 InlineCacheState StateFromFeedback() const override; |
421 Name* FindFirstName() const override; | 465 Name* FindFirstName() const override; |
422 }; | 466 }; |
423 } | 467 } |
424 } // namespace v8::internal | 468 } // namespace v8::internal |
425 | 469 |
426 #endif // V8_TRANSITIONS_H_ | 470 #endif // V8_TRANSITIONS_H_ |
OLD | NEW |