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

Side by Side Diff: src/ic/ic.h

Issue 1199983002: [strong] Implement strong property access semantics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add TODOs Created 5 years, 5 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 | « src/ic/ia32/ic-ia32.cc ('k') | src/ic/ic.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_IC_H_ 5 #ifndef V8_IC_H_
6 #define V8_IC_H_ 6 #define V8_IC_H_
7 7
8 #include "src/ic/ic-state.h" 8 #include "src/ic/ic-state.h"
9 #include "src/macro-assembler.h" 9 #include "src/macro-assembler.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 CallICState::CallType call_type); 347 CallICState::CallType call_type);
348 static Handle<Code> initialize_stub_in_optimized_code( 348 static Handle<Code> initialize_stub_in_optimized_code(
349 Isolate* isolate, int argc, CallICState::CallType call_type); 349 Isolate* isolate, int argc, CallICState::CallType call_type);
350 350
351 static void Clear(Isolate* isolate, Code* host, CallICNexus* nexus); 351 static void Clear(Isolate* isolate, Code* host, CallICNexus* nexus);
352 }; 352 };
353 353
354 354
355 class LoadIC : public IC { 355 class LoadIC : public IC {
356 public: 356 public:
357 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { 357 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode,
358 return LoadICState(contextual_mode).GetExtraICState(); 358 LanguageMode language_mode) {
359 return LoadICState(contextual_mode, language_mode).GetExtraICState();
359 } 360 }
360 361
361 ContextualMode contextual_mode() const { 362 ContextualMode contextual_mode() const {
362 return LoadICState::GetContextualMode(extra_ic_state()); 363 return LoadICState::GetContextualMode(extra_ic_state());
363 } 364 }
364 365
366 LanguageMode language_mode() const {
367 return LoadICState::GetLanguageMode(extra_ic_state());
368 }
369
365 LoadIC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL) 370 LoadIC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL)
366 : IC(depth, isolate, nexus) { 371 : IC(depth, isolate, nexus) {
367 DCHECK(nexus != NULL); 372 DCHECK(nexus != NULL);
368 DCHECK(IsLoadStub()); 373 DCHECK(IsLoadStub());
369 } 374 }
370 375
371 // TODO(mvstanton): The for_queries_only is because we have a case where we 376 // TODO(mvstanton): The for_queries_only is because we have a case where we
372 // construct an IC only to gather the contextual mode, and we don't have 377 // construct an IC only to gather the contextual mode, and we don't have
373 // vector/slot information. for_queries_only is a temporary hack to enable the 378 // vector/slot information. for_queries_only is a temporary hack to enable the
374 // strong DCHECK protection around vector/slot. 379 // strong DCHECK protection around vector/slot.
375 LoadIC(FrameDepth depth, Isolate* isolate, bool for_queries_only) 380 LoadIC(FrameDepth depth, Isolate* isolate, bool for_queries_only)
376 : IC(depth, isolate, NULL, for_queries_only) { 381 : IC(depth, isolate, NULL, for_queries_only) {
377 DCHECK(IsLoadStub()); 382 DCHECK(IsLoadStub());
378 } 383 }
379 384
380 // Returns if this IC is for contextual (no explicit receiver) 385 // Returns if this IC is for contextual (no explicit receiver)
381 // access to properties. 386 // access to properties.
382 bool IsUndeclaredGlobal(Handle<Object> receiver) { 387 bool IsUndeclaredGlobal(Handle<Object> receiver) {
383 if (receiver->IsGlobalObject()) { 388 if (receiver->IsGlobalObject()) {
384 return contextual_mode() == CONTEXTUAL; 389 return contextual_mode() == CONTEXTUAL;
385 } else { 390 } else {
386 DCHECK(contextual_mode() != CONTEXTUAL); 391 DCHECK(contextual_mode() != CONTEXTUAL);
387 return false; 392 return false;
388 } 393 }
389 } 394 }
390 395
391 // Code generator routines. 396 // Code generator routines.
392 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } 397 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
393 static void GenerateMiss(MacroAssembler* masm); 398 static void GenerateMiss(MacroAssembler* masm);
394 static void GenerateNormal(MacroAssembler* masm); 399 static void GenerateRuntimeGetProperty(MacroAssembler* masm,
395 static void GenerateRuntimeGetProperty(MacroAssembler* masm); 400 LanguageMode language_mode);
401 static void GenerateNormal(MacroAssembler* masm, LanguageMode language_mode);
396 402
397 static Handle<Code> initialize_stub(Isolate* isolate, 403 static Handle<Code> initialize_stub(Isolate* isolate,
398 ExtraICState extra_state); 404 ExtraICState extra_state);
399 static Handle<Code> initialize_stub_in_optimized_code( 405 static Handle<Code> initialize_stub_in_optimized_code(
400 Isolate* isolate, ExtraICState extra_state, State initialization_state); 406 Isolate* isolate, ExtraICState extra_state, State initialization_state);
401 407
402 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, 408 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object,
403 Handle<Name> name); 409 Handle<Name> name);
404 410
405 static void Clear(Isolate* isolate, Code* host, LoadICNexus* nexus); 411 static void Clear(Isolate* isolate, Code* host, LoadICNexus* nexus);
406 412
407 protected: 413 protected:
408 inline void set_target(Code* code); 414 inline void set_target(Code* code);
409 415
410 Handle<Code> slow_stub() const { 416 Handle<Code> slow_stub() const {
411 if (kind() == Code::LOAD_IC) { 417 if (kind() == Code::LOAD_IC) {
412 return isolate()->builtins()->LoadIC_Slow(); 418 return is_strong(language_mode())
419 ? isolate()->builtins()->LoadIC_Slow_Strong()
420 : isolate()->builtins()->LoadIC_Slow();
413 } else { 421 } else {
414 DCHECK_EQ(Code::KEYED_LOAD_IC, kind()); 422 DCHECK_EQ(Code::KEYED_LOAD_IC, kind());
415 return isolate()->builtins()->KeyedLoadIC_Slow(); 423 return is_strong(language_mode())
424 ? isolate()->builtins()->KeyedLoadIC_Slow_Strong()
425 : isolate()->builtins()->KeyedLoadIC_Slow();
416 } 426 }
417 } 427 }
418 428
419 Handle<Code> megamorphic_stub() override; 429 Handle<Code> megamorphic_stub() override;
420 430
421 // Update the inline cache and the global stub cache based on the 431 // Update the inline cache and the global stub cache based on the
422 // lookup result. 432 // lookup result.
423 void UpdateCaches(LookupIterator* lookup); 433 void UpdateCaches(LookupIterator* lookup);
424 434
425 virtual Handle<Code> CompileHandler(LookupIterator* lookup, 435 virtual Handle<Code> CompileHandler(LookupIterator* lookup,
426 Handle<Object> unused, 436 Handle<Object> unused,
427 CacheHolderFlag cache_holder) override; 437 CacheHolderFlag cache_holder) override;
428 438
429 private: 439 private:
430 Handle<Code> SimpleFieldLoad(FieldIndex index); 440 Handle<Code> SimpleFieldLoad(FieldIndex index);
431 441
432 static void Clear(Isolate* isolate, Address address, Code* target, 442 static void Clear(Isolate* isolate, Address address, Code* target,
433 Address constant_pool); 443 Address constant_pool);
434 444
435 friend class IC; 445 friend class IC;
436 }; 446 };
437 447
438 448
439 class KeyedLoadIC : public LoadIC { 449 class KeyedLoadIC : public LoadIC {
440 public: 450 public:
441 // ExtraICState bits (building on IC) 451 // ExtraICState bits (building on IC)
442 class IcCheckTypeField : public BitField<IcCheckType, 1, 1> {}; 452 class IcCheckTypeField
453 : public BitField<IcCheckType, LoadICState::kNextBitFieldOffset, 1> {};
443 454
444 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode, 455 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode,
456 LanguageMode language_mode,
445 IcCheckType key_type) { 457 IcCheckType key_type) {
446 return LoadICState(contextual_mode).GetExtraICState() | 458 return LoadICState(contextual_mode, language_mode).GetExtraICState() |
447 IcCheckTypeField::encode(key_type); 459 IcCheckTypeField::encode(key_type);
448 } 460 }
449 461
450 static IcCheckType GetKeyType(ExtraICState extra_state) { 462 static IcCheckType GetKeyType(ExtraICState extra_state) {
451 return IcCheckTypeField::decode(extra_state); 463 return IcCheckTypeField::decode(extra_state);
452 } 464 }
453 465
454 KeyedLoadIC(FrameDepth depth, Isolate* isolate, 466 KeyedLoadIC(FrameDepth depth, Isolate* isolate,
455 KeyedLoadICNexus* nexus = NULL) 467 KeyedLoadICNexus* nexus = NULL)
456 : LoadIC(depth, isolate, nexus) { 468 : LoadIC(depth, isolate, nexus) {
457 DCHECK(nexus != NULL); 469 DCHECK(nexus != NULL);
458 DCHECK(target()->is_keyed_load_stub()); 470 DCHECK(target()->is_keyed_load_stub());
459 } 471 }
460 472
461 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, 473 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object,
462 Handle<Object> key); 474 Handle<Object> key);
463 475
464 // Code generator routines. 476 // Code generator routines.
465 static void GenerateMiss(MacroAssembler* masm); 477 static void GenerateMiss(MacroAssembler* masm);
466 static void GenerateRuntimeGetProperty(MacroAssembler* masm); 478 static void GenerateRuntimeGetProperty(MacroAssembler* masm,
479 LanguageMode language_mode);
467 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } 480 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
468 static void GenerateMegamorphic(MacroAssembler* masm); 481 static void GenerateMegamorphic(MacroAssembler* masm,
482 LanguageMode language_mode);
469 483
470 // Bit mask to be tested against bit field for the cases when 484 // Bit mask to be tested against bit field for the cases when
471 // generic stub should go into slow case. 485 // generic stub should go into slow case.
472 // Access check is necessary explicitly since generic stub does not perform 486 // Access check is necessary explicitly since generic stub does not perform
473 // map checks. 487 // map checks.
474 static const int kSlowCaseBitFieldMask = 488 static const int kSlowCaseBitFieldMask =
475 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); 489 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor);
476 490
477 static Handle<Code> initialize_stub(Isolate* isolate); 491 static Handle<Code> initialize_stub(Isolate* isolate,
492 ExtraICState extra_state);
478 static Handle<Code> initialize_stub_in_optimized_code( 493 static Handle<Code> initialize_stub_in_optimized_code(
479 Isolate* isolate, State initialization_state); 494 Isolate* isolate, State initialization_state, ExtraICState extra_state);
480 static Handle<Code> ChooseMegamorphicStub(Isolate* isolate); 495 static Handle<Code> ChooseMegamorphicStub(Isolate* isolate,
496 ExtraICState extra_state);
481 497
482 static void Clear(Isolate* isolate, Code* host, KeyedLoadICNexus* nexus); 498 static void Clear(Isolate* isolate, Code* host, KeyedLoadICNexus* nexus);
483 499
484 protected: 500 protected:
485 // receiver is HeapObject because it could be a String or a JSObject 501 // receiver is HeapObject because it could be a String or a JSObject
486 Handle<Code> LoadElementStub(Handle<HeapObject> receiver); 502 Handle<Code> LoadElementStub(Handle<HeapObject> receiver);
487 503
488 private: 504 private:
489 static void Clear(Isolate* isolate, Address address, Code* target, 505 static void Clear(Isolate* isolate, Address address, Code* target,
490 Address constant_pool); 506 Address constant_pool);
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 766
751 // Support functions for interceptor handlers. 767 // Support functions for interceptor handlers.
752 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); 768 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly);
753 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); 769 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor);
754 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); 770 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor);
755 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); 771 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor);
756 } 772 }
757 } // namespace v8::internal 773 } // namespace v8::internal
758 774
759 #endif // V8_IC_H_ 775 #endif // V8_IC_H_
OLDNEW
« no previous file with comments | « src/ic/ia32/ic-ia32.cc ('k') | src/ic/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698