| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Alias the inline cache state type to make the IC code more readable. | 80 // Alias the inline cache state type to make the IC code more readable. |
| 81 typedef InlineCacheState State; | 81 typedef InlineCacheState State; |
| 82 | 82 |
| 83 // The IC code is either invoked with no extra frames on the stack | 83 // The IC code is either invoked with no extra frames on the stack |
| 84 // or with a single extra frame for supporting calls. | 84 // or with a single extra frame for supporting calls. |
| 85 enum FrameDepth { | 85 enum FrameDepth { |
| 86 NO_EXTRA_FRAME = 0, | 86 NO_EXTRA_FRAME = 0, |
| 87 EXTRA_CALL_FRAME = 1 | 87 EXTRA_CALL_FRAME = 1 |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 // ExtraICState shared by all ICs. |
| 91 class Contextual: public BitField<ContextualMode, 0, 1> {}; |
| 92 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); |
| 93 static ExtraICState ComputeExtraICState(ContextualMode mode) { |
| 94 return Contextual::encode(mode); |
| 95 } |
| 96 |
| 97 static ContextualMode GetContextualMode(ExtraICState state) { |
| 98 return Contextual::decode(state); |
| 99 } |
| 100 |
| 101 static const ExtraICState kContextualState = |
| 102 static_cast<int>(CONTEXTUAL) << Contextual::kShift; |
| 103 |
| 90 // Construct the IC structure with the given number of extra | 104 // Construct the IC structure with the given number of extra |
| 91 // JavaScript frames on the stack. | 105 // JavaScript frames on the stack. |
| 92 IC(FrameDepth depth, Isolate* isolate); | 106 IC(FrameDepth depth, Isolate* isolate); |
| 93 virtual ~IC() {} | 107 virtual ~IC() {} |
| 94 | 108 |
| 95 State state() const { return state_; } | 109 State state() const { return state_; } |
| 96 inline Address address() const; | 110 inline Address address() const; |
| 97 | 111 |
| 98 // Compute the current IC state based on the target stub, receiver and name. | 112 // Compute the current IC state based on the target stub, receiver and name. |
| 99 void UpdateState(Handle<Object> receiver, Handle<Object> name); | 113 void UpdateState(Handle<Object> receiver, Handle<Object> name); |
| 100 void MarkMonomorphicPrototypeFailure() { | 114 void MarkMonomorphicPrototypeFailure() { |
| 101 state_ = MONOMORPHIC_PROTOTYPE_FAILURE; | 115 state_ = MONOMORPHIC_PROTOTYPE_FAILURE; |
| 102 } | 116 } |
| 103 | 117 |
| 104 // Clear the inline cache to initial state. | 118 // Clear the inline cache to initial state. |
| 105 static void Clear(Isolate* isolate, Address address); | 119 static void Clear(Isolate* isolate, Address address); |
| 106 | 120 |
| 107 // Computes the reloc info for this IC. This is a fairly expensive | |
| 108 // operation as it has to search through the heap to find the code | |
| 109 // object that contains this IC site. | |
| 110 RelocInfo::Mode ComputeMode(); | |
| 111 | |
| 112 // Returns if this IC is for contextual (no explicit receiver) | 121 // Returns if this IC is for contextual (no explicit receiver) |
| 113 // access to properties. | 122 // access to properties. |
| 114 bool IsUndeclaredGlobal(Handle<Object> receiver) { | 123 bool IsUndeclaredGlobal(Handle<Object> receiver) { |
| 115 if (receiver->IsGlobalObject()) { | 124 if (receiver->IsGlobalObject()) { |
| 116 return SlowIsUndeclaredGlobal(); | 125 return IsContextual(); |
| 117 } else { | 126 } else { |
| 118 ASSERT(!SlowIsUndeclaredGlobal()); | 127 ASSERT(!IsContextual()); |
| 119 return false; | 128 return false; |
| 120 } | 129 } |
| 121 } | 130 } |
| 122 | 131 |
| 123 bool SlowIsUndeclaredGlobal() { | |
| 124 return ComputeMode() == RelocInfo::CODE_TARGET_CONTEXT; | |
| 125 } | |
| 126 | |
| 127 #ifdef DEBUG | 132 #ifdef DEBUG |
| 128 bool IsLoadStub() { | 133 bool IsLoadStub() { |
| 129 return target()->is_load_stub() || target()->is_keyed_load_stub(); | 134 return target()->is_load_stub() || target()->is_keyed_load_stub(); |
| 130 } | 135 } |
| 131 | 136 |
| 132 bool IsStoreStub() { | 137 bool IsStoreStub() { |
| 133 return target()->is_store_stub() || target()->is_keyed_store_stub(); | 138 return target()->is_store_stub() || target()->is_keyed_store_stub(); |
| 134 } | 139 } |
| 135 | 140 |
| 136 bool IsCallStub() { | 141 bool IsCallStub() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 160 | 165 |
| 161 // Utility functions to convert maps to types and back. There are two special | 166 // Utility functions to convert maps to types and back. There are two special |
| 162 // cases: | 167 // cases: |
| 163 // - The heap_number_map is used as a marker which includes heap numbers as | 168 // - The heap_number_map is used as a marker which includes heap numbers as |
| 164 // well as smis. | 169 // well as smis. |
| 165 // - The oddball map is only used for booleans. | 170 // - The oddball map is only used for booleans. |
| 166 static Handle<Map> TypeToMap(Type* type, Isolate* isolate); | 171 static Handle<Map> TypeToMap(Type* type, Isolate* isolate); |
| 167 static Type* MapToType(Handle<Map> type); | 172 static Type* MapToType(Handle<Map> type); |
| 168 static Handle<Type> CurrentTypeOf(Handle<Object> object, Isolate* isolate); | 173 static Handle<Type> CurrentTypeOf(Handle<Object> object, Isolate* isolate); |
| 169 | 174 |
| 175 ContextualMode contextual_mode() const { |
| 176 return Contextual::decode(extra_ic_state()); |
| 177 } |
| 178 |
| 179 bool IsContextual() const { return contextual_mode() == CONTEXTUAL; } |
| 180 |
| 170 protected: | 181 protected: |
| 171 // Get the call-site target; used for determining the state. | 182 // Get the call-site target; used for determining the state. |
| 172 Handle<Code> target() const { return target_; } | 183 Handle<Code> target() const { return target_; } |
| 173 | 184 |
| 174 Address fp() const { return fp_; } | 185 Address fp() const { return fp_; } |
| 175 Address pc() const { return *pc_address_; } | 186 Address pc() const { return *pc_address_; } |
| 176 Isolate* isolate() const { return isolate_; } | 187 Isolate* isolate() const { return isolate_; } |
| 177 | 188 |
| 178 #ifdef ENABLE_DEBUGGER_SUPPORT | 189 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 179 // Computes the address in the original code when the code running is | 190 // Computes the address in the original code when the code running is |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 259 } |
| 249 virtual Handle<Code> generic_stub() const { | 260 virtual Handle<Code> generic_stub() const { |
| 250 UNREACHABLE(); | 261 UNREACHABLE(); |
| 251 return Handle<Code>::null(); | 262 return Handle<Code>::null(); |
| 252 } | 263 } |
| 253 | 264 |
| 254 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, | 265 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, |
| 255 Handle<String> name); | 266 Handle<String> name); |
| 256 void TryRemoveInvalidHandlers(Handle<Map> map, Handle<String> name); | 267 void TryRemoveInvalidHandlers(Handle<Map> map, Handle<String> name); |
| 257 | 268 |
| 258 virtual ExtraICState extra_ic_state() { return kNoExtraICState; } | 269 ExtraICState extra_ic_state() const { return extra_ic_state_; } |
| 270 void set_extra_ic_state(ExtraICState state) { |
| 271 extra_ic_state_ = state; |
| 272 } |
| 259 | 273 |
| 260 private: | 274 private: |
| 261 Code* raw_target() const { return GetTargetAtAddress(address()); } | 275 Code* raw_target() const { return GetTargetAtAddress(address()); } |
| 262 | 276 |
| 263 // Frame pointer for the frame that uses (calls) the IC. | 277 // Frame pointer for the frame that uses (calls) the IC. |
| 264 Address fp_; | 278 Address fp_; |
| 265 | 279 |
| 266 // All access to the program counter of an IC structure is indirect | 280 // All access to the program counter of an IC structure is indirect |
| 267 // to make the code GC safe. This feature is crucial since | 281 // to make the code GC safe. This feature is crucial since |
| 268 // GetProperty and SetProperty are called and they in turn might | 282 // GetProperty and SetProperty are called and they in turn might |
| 269 // invoke the garbage collector. | 283 // invoke the garbage collector. |
| 270 Address* pc_address_; | 284 Address* pc_address_; |
| 271 | 285 |
| 272 Isolate* isolate_; | 286 Isolate* isolate_; |
| 273 | 287 |
| 274 // The original code target that missed. | 288 // The original code target that missed. |
| 275 Handle<Code> target_; | 289 Handle<Code> target_; |
| 276 State state_; | 290 State state_; |
| 277 bool target_set_; | 291 bool target_set_; |
| 278 | 292 |
| 293 ExtraICState extra_ic_state_; |
| 294 |
| 279 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); | 295 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); |
| 280 }; | 296 }; |
| 281 | 297 |
| 282 | 298 |
| 283 // An IC_Utility encapsulates IC::UtilityId. It exists mainly because you | 299 // An IC_Utility encapsulates IC::UtilityId. It exists mainly because you |
| 284 // cannot make forward declarations to an enum. | 300 // cannot make forward declarations to an enum. |
| 285 class IC_Utility { | 301 class IC_Utility { |
| 286 public: | 302 public: |
| 287 explicit IC_Utility(IC::UtilityId id) | 303 explicit IC_Utility(IC::UtilityId id) |
| 288 : address_(IC::AddressFromUtilityId(id)), id_(id) {} | 304 : address_(IC::AddressFromUtilityId(id)), id_(id) {} |
| 289 | 305 |
| 290 Address address() const { return address_; } | 306 Address address() const { return address_; } |
| 291 | 307 |
| 292 IC::UtilityId id() const { return id_; } | 308 IC::UtilityId id() const { return id_; } |
| 293 private: | 309 private: |
| 294 Address address_; | 310 Address address_; |
| 295 IC::UtilityId id_; | 311 IC::UtilityId id_; |
| 296 }; | 312 }; |
| 297 | 313 |
| 298 | 314 |
| 299 class CallICBase: public IC { | 315 class CallICBase: public IC { |
| 300 public: | 316 public: |
| 301 // ExtraICState bits | 317 // ExtraICState bits |
| 302 class Contextual: public BitField<ContextualMode, 0, 1> {}; | |
| 303 class StringStubState: public BitField<StringStubFeedback, 1, 1> {}; | 318 class StringStubState: public BitField<StringStubFeedback, 1, 1> {}; |
| 304 static ExtraICState ComputeExtraICState(ContextualMode mode, | 319 static ExtraICState ComputeExtraICState(ContextualMode mode, |
| 305 StringStubFeedback feedback) { | 320 StringStubFeedback feedback) { |
| 306 return Contextual::encode(mode) | StringStubState::encode(feedback); | 321 return Contextual::encode(mode) | StringStubState::encode(feedback); |
| 307 } | 322 } |
| 308 | 323 |
| 309 // Returns a JSFunction or a Failure. | 324 // Returns a JSFunction or a Failure. |
| 310 MUST_USE_RESULT MaybeObject* LoadFunction(Handle<Object> object, | 325 MUST_USE_RESULT MaybeObject* LoadFunction(Handle<Object> object, |
| 311 Handle<String> name); | 326 Handle<String> name); |
| 312 | 327 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 368 |
| 354 Code::Kind kind_; | 369 Code::Kind kind_; |
| 355 | 370 |
| 356 friend class IC; | 371 friend class IC; |
| 357 }; | 372 }; |
| 358 | 373 |
| 359 | 374 |
| 360 class CallIC: public CallICBase { | 375 class CallIC: public CallICBase { |
| 361 public: | 376 public: |
| 362 explicit CallIC(Isolate* isolate) | 377 explicit CallIC(Isolate* isolate) |
| 363 : CallICBase(Code::CALL_IC, isolate), | 378 : CallICBase(Code::CALL_IC, isolate) { |
| 364 extra_ic_state_(target()->extra_ic_state()) { | |
| 365 ASSERT(target()->is_call_stub()); | 379 ASSERT(target()->is_call_stub()); |
| 366 } | 380 } |
| 367 | 381 |
| 368 // Code generator routines. | 382 // Code generator routines. |
| 369 static void GenerateInitialize(MacroAssembler* masm, | 383 static void GenerateInitialize(MacroAssembler* masm, |
| 370 int argc, | 384 int argc, |
| 371 ExtraICState extra_state) { | 385 ExtraICState extra_state) { |
| 372 GenerateMiss(masm, argc, extra_state); | 386 GenerateMiss(masm, argc, extra_state); |
| 373 } | 387 } |
| 374 | 388 |
| 375 static void GenerateMiss(MacroAssembler* masm, | 389 static void GenerateMiss(MacroAssembler* masm, |
| 376 int argc, | 390 int argc, |
| 377 ExtraICState extra_state) { | 391 ExtraICState extra_state) { |
| 378 CallICBase::GenerateMiss(masm, argc, IC::kCallIC_Miss, extra_state); | 392 CallICBase::GenerateMiss(masm, argc, IC::kCallIC_Miss, extra_state); |
| 379 } | 393 } |
| 380 | 394 |
| 381 static void GenerateMegamorphic(MacroAssembler* masm, | 395 static void GenerateMegamorphic(MacroAssembler* masm, |
| 382 int argc, | 396 int argc, |
| 383 ExtraICState extra_ic_state); | 397 ExtraICState extra_ic_state); |
| 384 | 398 |
| 385 static void GenerateNormal(MacroAssembler* masm, int argc) { | 399 static void GenerateNormal(MacroAssembler* masm, int argc) { |
| 386 CallICBase::GenerateNormal(masm, argc); | 400 CallICBase::GenerateNormal(masm, argc); |
| 387 GenerateMiss(masm, argc, kNoExtraICState); | 401 GenerateMiss(masm, argc, kNoExtraICState); |
| 388 } | 402 } |
| 389 bool TryUpdateExtraICState(LookupResult* lookup, Handle<Object> object); | 403 bool TryUpdateExtraICState(LookupResult* lookup, Handle<Object> object); |
| 390 | |
| 391 protected: | |
| 392 virtual ExtraICState extra_ic_state() { return extra_ic_state_; } | |
| 393 | |
| 394 private: | |
| 395 ExtraICState extra_ic_state_; | |
| 396 }; | 404 }; |
| 397 | 405 |
| 398 | 406 |
| 399 class KeyedCallIC: public CallICBase { | 407 class KeyedCallIC: public CallICBase { |
| 400 public: | 408 public: |
| 401 explicit KeyedCallIC(Isolate* isolate) | 409 explicit KeyedCallIC(Isolate* isolate) |
| 402 : CallICBase(Code::KEYED_CALL_IC, isolate) { | 410 : CallICBase(Code::KEYED_CALL_IC, isolate) { |
| 403 ASSERT(target()->is_keyed_call_stub()); | 411 ASSERT(target()->is_keyed_call_stub()); |
| 404 } | 412 } |
| 405 | 413 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 417 } | 425 } |
| 418 | 426 |
| 419 static void GenerateMegamorphic(MacroAssembler* masm, int argc); | 427 static void GenerateMegamorphic(MacroAssembler* masm, int argc); |
| 420 static void GenerateNormal(MacroAssembler* masm, int argc); | 428 static void GenerateNormal(MacroAssembler* masm, int argc); |
| 421 static void GenerateNonStrictArguments(MacroAssembler* masm, int argc); | 429 static void GenerateNonStrictArguments(MacroAssembler* masm, int argc); |
| 422 }; | 430 }; |
| 423 | 431 |
| 424 | 432 |
| 425 class LoadIC: public IC { | 433 class LoadIC: public IC { |
| 426 public: | 434 public: |
| 427 explicit LoadIC(FrameDepth depth, Isolate* isolate) : IC(depth, isolate) { | 435 explicit LoadIC(FrameDepth depth, Isolate* isolate) |
| 436 : IC(depth, isolate) { |
| 428 ASSERT(IsLoadStub()); | 437 ASSERT(IsLoadStub()); |
| 429 } | 438 } |
| 430 | 439 |
| 431 // Code generator routines. | 440 // Code generator routines. |
| 432 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 441 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 433 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 442 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 434 GenerateMiss(masm); | 443 GenerateMiss(masm); |
| 435 } | 444 } |
| 436 static void GenerateMiss(MacroAssembler* masm); | 445 static void GenerateMiss(MacroAssembler* masm); |
| 437 static void GenerateMegamorphic(MacroAssembler* masm); | 446 static void GenerateMegamorphic(MacroAssembler* masm, ContextualMode mode); |
| 438 static void GenerateNormal(MacroAssembler* masm); | 447 static void GenerateNormal(MacroAssembler* masm); |
| 439 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 448 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
| 440 | 449 |
| 450 static Handle<Code> initialize_stub(Isolate* isolate, ContextualMode mode); |
| 451 |
| 441 MUST_USE_RESULT MaybeObject* Load(Handle<Object> object, | 452 MUST_USE_RESULT MaybeObject* Load(Handle<Object> object, |
| 442 Handle<String> name); | 453 Handle<String> name); |
| 443 | 454 |
| 444 protected: | 455 protected: |
| 445 virtual Code::Kind kind() const { return Code::LOAD_IC; } | 456 virtual Code::Kind kind() const { return Code::LOAD_IC; } |
| 446 | 457 |
| 447 virtual Handle<Code> slow_stub() const { | 458 virtual Handle<Code> slow_stub() const { |
| 448 return isolate()->builtins()->LoadIC_Slow(); | 459 return isolate()->builtins()->LoadIC_Slow(); |
| 449 } | 460 } |
| 450 | 461 |
| 451 virtual Handle<Code> megamorphic_stub() { | 462 virtual Handle<Code> megamorphic_stub(); |
| 452 return isolate()->builtins()->LoadIC_Megamorphic(); | |
| 453 } | |
| 454 | 463 |
| 455 // Update the inline cache and the global stub cache based on the | 464 // Update the inline cache and the global stub cache based on the |
| 456 // lookup result. | 465 // lookup result. |
| 457 void UpdateCaches(LookupResult* lookup, | 466 void UpdateCaches(LookupResult* lookup, |
| 458 Handle<Object> object, | 467 Handle<Object> object, |
| 459 Handle<String> name); | 468 Handle<String> name); |
| 460 | 469 |
| 461 virtual Handle<Code> CompileHandler(LookupResult* lookup, | 470 virtual Handle<Code> CompileHandler(LookupResult* lookup, |
| 462 Handle<Object> object, | 471 Handle<Object> object, |
| 463 Handle<String> name, | 472 Handle<String> name, |
| 464 Handle<Object> unused, | 473 Handle<Object> unused, |
| 465 InlineCacheHolderFlag cache_holder); | 474 InlineCacheHolderFlag cache_holder); |
| 466 | 475 |
| 467 private: | 476 private: |
| 468 // Stub accessors. | 477 // Stub accessors. |
| 469 static Handle<Code> initialize_stub(Isolate* isolate) { | 478 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
| 470 return isolate->builtins()->LoadIC_Initialize(); | 479 ContextualMode mode); |
| 471 } | |
| 472 | |
| 473 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { | |
| 474 return isolate->builtins()->LoadIC_PreMonomorphic(); | |
| 475 } | |
| 476 | 480 |
| 477 virtual Handle<Code> pre_monomorphic_stub() { | 481 virtual Handle<Code> pre_monomorphic_stub() { |
| 478 return pre_monomorphic_stub(isolate()); | 482 return pre_monomorphic_stub(isolate(), contextual_mode()); |
| 479 } | 483 } |
| 480 | 484 |
| 481 Handle<Code> SimpleFieldLoad(int offset, | 485 Handle<Code> SimpleFieldLoad(int offset, |
| 482 bool inobject = true, | 486 bool inobject = true, |
| 483 Representation representation = | 487 Representation representation = |
| 484 Representation::Tagged()); | 488 Representation::Tagged()); |
| 485 | 489 |
| 486 static void Clear(Isolate* isolate, Address address, Code* target); | 490 static void Clear(Isolate* isolate, Address address, Code* target); |
| 487 | 491 |
| 488 friend class IC; | 492 friend class IC; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 return isolate()->builtins()->KeyedLoadIC_Generic(); | 534 return isolate()->builtins()->KeyedLoadIC_Generic(); |
| 531 } | 535 } |
| 532 virtual Handle<Code> slow_stub() const { | 536 virtual Handle<Code> slow_stub() const { |
| 533 return isolate()->builtins()->KeyedLoadIC_Slow(); | 537 return isolate()->builtins()->KeyedLoadIC_Slow(); |
| 534 } | 538 } |
| 535 | 539 |
| 536 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } | 540 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } |
| 537 | 541 |
| 538 private: | 542 private: |
| 539 // Stub accessors. | 543 // Stub accessors. |
| 540 static Handle<Code> initialize_stub(Isolate* isolate) { | |
| 541 return isolate->builtins()->KeyedLoadIC_Initialize(); | |
| 542 } | |
| 543 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { | 544 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { |
| 544 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); | 545 return isolate->builtins()->KeyedLoadIC_PreMonomorphic(); |
| 545 } | 546 } |
| 546 virtual Handle<Code> pre_monomorphic_stub() { | 547 virtual Handle<Code> pre_monomorphic_stub() { |
| 547 return pre_monomorphic_stub(isolate()); | 548 return pre_monomorphic_stub(isolate()); |
| 548 } | 549 } |
| 549 Handle<Code> indexed_interceptor_stub() { | 550 Handle<Code> indexed_interceptor_stub() { |
| 550 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); | 551 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); |
| 551 } | 552 } |
| 552 Handle<Code> non_strict_arguments_stub() { | 553 Handle<Code> non_strict_arguments_stub() { |
| 553 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); | 554 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); |
| 554 } | 555 } |
| 555 Handle<Code> string_stub() { | 556 Handle<Code> string_stub() { |
| 556 return isolate()->builtins()->KeyedLoadIC_String(); | 557 return isolate()->builtins()->KeyedLoadIC_String(); |
| 557 } | 558 } |
| 558 | 559 |
| 559 static void Clear(Isolate* isolate, Address address, Code* target); | 560 static void Clear(Isolate* isolate, Address address, Code* target); |
| 560 | 561 |
| 561 friend class IC; | 562 friend class IC; |
| 562 }; | 563 }; |
| 563 | 564 |
| 564 | 565 |
| 565 class StoreIC: public IC { | 566 class StoreIC: public IC { |
| 566 public: | 567 public: |
| 567 // ExtraICState bits | 568 // ExtraICState bits |
| 568 class StrictModeState: public BitField<StrictModeFlag, 0, 1> {}; | 569 class StrictModeState: public BitField<StrictModeFlag, 1, 1> {}; |
| 569 static ExtraICState ComputeExtraICState(StrictModeFlag flag) { | 570 static ExtraICState ComputeExtraICState(StrictModeFlag flag) { |
| 570 return StrictModeState::encode(flag); | 571 return StrictModeState::encode(flag); |
| 571 } | 572 } |
| 572 | 573 |
| 574 static ExtraICState ComputeExtraICState(StrictModeFlag flag, |
| 575 ContextualMode mode) { |
| 576 return StrictModeState::encode(flag) | Contextual::encode(mode); |
| 577 } |
| 578 |
| 573 static StrictModeFlag GetStrictMode(ExtraICState state) { | 579 static StrictModeFlag GetStrictMode(ExtraICState state) { |
| 574 return StrictModeState::decode(state); | 580 return StrictModeState::decode(state); |
| 575 } | 581 } |
| 576 | 582 |
| 577 // For convenience, a statically declared encoding of strict mode extra | 583 // For convenience, a statically declared encoding of strict mode extra |
| 578 // IC state. | 584 // IC state. |
| 579 static const ExtraICState kStrictModeState = | 585 static const ExtraICState kStrictModeState = |
| 580 1 << StrictModeState::kShift; | 586 1 << StrictModeState::kShift; |
| 581 | 587 |
| 582 StoreIC(FrameDepth depth, Isolate* isolate) | 588 StoreIC(FrameDepth depth, Isolate* isolate) |
| 583 : IC(depth, isolate), | 589 : IC(depth, isolate) { |
| 584 strict_mode_(GetStrictMode(target()->extra_ic_state())) { | |
| 585 ASSERT(IsStoreStub()); | 590 ASSERT(IsStoreStub()); |
| 586 } | 591 } |
| 587 | 592 |
| 588 StrictModeFlag strict_mode() const { return strict_mode_; } | 593 StrictModeFlag strict_mode() const { |
| 594 return StrictModeState::decode(extra_ic_state()); |
| 595 } |
| 589 | 596 |
| 590 // Code generators for stub routines. Only called once at startup. | 597 // Code generators for stub routines. Only called once at startup. |
| 591 static void GenerateSlow(MacroAssembler* masm); | 598 static void GenerateSlow(MacroAssembler* masm); |
| 592 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 599 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 593 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 600 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 594 GenerateMiss(masm); | 601 GenerateMiss(masm); |
| 595 } | 602 } |
| 596 static void GenerateMiss(MacroAssembler* masm); | 603 static void GenerateMiss(MacroAssembler* masm); |
| 597 static void GenerateMegamorphic(MacroAssembler* masm, | 604 static void GenerateMegamorphic(MacroAssembler* masm, |
| 598 ExtraICState extra_ic_state); | 605 ExtraICState extra_ic_state); |
| 599 static void GenerateNormal(MacroAssembler* masm); | 606 static void GenerateNormal(MacroAssembler* masm); |
| 600 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 607 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 601 StrictModeFlag strict_mode); | 608 StrictModeFlag strict_mode); |
| 602 | 609 |
| 610 static Handle<Code> initialize_stub(Isolate* isolate, |
| 611 StrictModeFlag strict_mode, |
| 612 ContextualMode mode); |
| 613 |
| 603 MUST_USE_RESULT MaybeObject* Store( | 614 MUST_USE_RESULT MaybeObject* Store( |
| 604 Handle<Object> object, | 615 Handle<Object> object, |
| 605 Handle<String> name, | 616 Handle<String> name, |
| 606 Handle<Object> value, | 617 Handle<Object> value, |
| 607 JSReceiver::StoreFromKeyed store_mode = | 618 JSReceiver::StoreFromKeyed store_mode = |
| 608 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); | 619 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); |
| 609 | 620 |
| 610 protected: | 621 protected: |
| 611 virtual Code::Kind kind() const { return Code::STORE_IC; } | 622 virtual Code::Kind kind() const { return Code::STORE_IC; } |
| 612 virtual Handle<Code> megamorphic_stub() { | 623 virtual Handle<Code> megamorphic_stub(); |
| 613 if (strict_mode() == kStrictMode) { | 624 |
| 614 return isolate()->builtins()->StoreIC_Megamorphic_Strict(); | |
| 615 } else { | |
| 616 return isolate()->builtins()->StoreIC_Megamorphic(); | |
| 617 } | |
| 618 } | |
| 619 // Stub accessors. | 625 // Stub accessors. |
| 620 virtual Handle<Code> generic_stub() const { | 626 virtual Handle<Code> generic_stub() const; |
| 621 if (strict_mode() == kStrictMode) { | |
| 622 return isolate()->builtins()->StoreIC_Generic_Strict(); | |
| 623 } else { | |
| 624 return isolate()->builtins()->StoreIC_Generic(); | |
| 625 } | |
| 626 } | |
| 627 | 627 |
| 628 virtual Handle<Code> slow_stub() const { | 628 virtual Handle<Code> slow_stub() const { |
| 629 return isolate()->builtins()->StoreIC_Slow(); | 629 return isolate()->builtins()->StoreIC_Slow(); |
| 630 } | 630 } |
| 631 | 631 |
| 632 virtual Handle<Code> pre_monomorphic_stub() { | 632 virtual Handle<Code> pre_monomorphic_stub() { |
| 633 return pre_monomorphic_stub(isolate(), strict_mode()); | 633 return pre_monomorphic_stub(isolate(), strict_mode(), contextual_mode()); |
| 634 } | 634 } |
| 635 | 635 |
| 636 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 636 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
| 637 StrictModeFlag strict_mode) { | 637 StrictModeFlag strict_mode, |
| 638 if (strict_mode == kStrictMode) { | 638 ContextualMode contextual_mode); |
| 639 return isolate->builtins()->StoreIC_PreMonomorphic_Strict(); | |
| 640 } else { | |
| 641 return isolate->builtins()->StoreIC_PreMonomorphic(); | |
| 642 } | |
| 643 } | |
| 644 | 639 |
| 645 // Update the inline cache and the global stub cache based on the | 640 // Update the inline cache and the global stub cache based on the |
| 646 // lookup result. | 641 // lookup result. |
| 647 void UpdateCaches(LookupResult* lookup, | 642 void UpdateCaches(LookupResult* lookup, |
| 648 Handle<JSObject> receiver, | 643 Handle<JSObject> receiver, |
| 649 Handle<String> name, | 644 Handle<String> name, |
| 650 Handle<Object> value); | 645 Handle<Object> value); |
| 651 virtual Handle<Code> CompileHandler(LookupResult* lookup, | 646 virtual Handle<Code> CompileHandler(LookupResult* lookup, |
| 652 Handle<Object> object, | 647 Handle<Object> object, |
| 653 Handle<String> name, | 648 Handle<String> name, |
| 654 Handle<Object> value, | 649 Handle<Object> value, |
| 655 InlineCacheHolderFlag cache_holder); | 650 InlineCacheHolderFlag cache_holder); |
| 656 | 651 |
| 657 virtual ExtraICState extra_ic_state() { | |
| 658 return ComputeExtraICState(strict_mode()); | |
| 659 } | |
| 660 | |
| 661 private: | 652 private: |
| 662 void set_target(Code* code) { | 653 void set_target(Code* code) { |
| 663 // Strict mode must be preserved across IC patching. | 654 // Strict mode must be preserved across IC patching. |
| 664 ASSERT(GetStrictMode(code->extra_ic_state()) == | 655 ASSERT(GetStrictMode(code->extra_ic_state()) == |
| 665 GetStrictMode(target()->extra_ic_state())); | 656 GetStrictMode(target()->extra_ic_state())); |
| 657 // As must the contextual mode |
| 658 ASSERT(GetContextualMode(code->extra_ic_state()) == |
| 659 GetContextualMode(target()->extra_ic_state())); |
| 666 IC::set_target(code); | 660 IC::set_target(code); |
| 667 } | 661 } |
| 668 | 662 |
| 669 static Handle<Code> initialize_stub(Isolate* isolate, | |
| 670 StrictModeFlag strict_mode) { | |
| 671 if (strict_mode == kStrictMode) { | |
| 672 return isolate->builtins()->StoreIC_Initialize_Strict(); | |
| 673 } else { | |
| 674 return isolate->builtins()->StoreIC_Initialize(); | |
| 675 } | |
| 676 } | |
| 677 | |
| 678 static void Clear(Isolate* isolate, Address address, Code* target); | 663 static void Clear(Isolate* isolate, Address address, Code* target); |
| 679 | 664 |
| 680 StrictModeFlag strict_mode_; | |
| 681 | |
| 682 friend class IC; | 665 friend class IC; |
| 683 }; | 666 }; |
| 684 | 667 |
| 685 | 668 |
| 686 enum KeyedStoreCheckMap { | 669 enum KeyedStoreCheckMap { |
| 687 kDontCheckMap, | 670 kDontCheckMap, |
| 688 kCheckMap | 671 kCheckMap |
| 689 }; | 672 }; |
| 690 | 673 |
| 691 | 674 |
| 692 enum KeyedStoreIncrementLength { | 675 enum KeyedStoreIncrementLength { |
| 693 kDontIncrementLength, | 676 kDontIncrementLength, |
| 694 kIncrementLength | 677 kIncrementLength |
| 695 }; | 678 }; |
| 696 | 679 |
| 697 | 680 |
| 698 class KeyedStoreIC: public StoreIC { | 681 class KeyedStoreIC: public StoreIC { |
| 699 public: | 682 public: |
| 700 // ExtraICState bits (building on IC) | 683 // ExtraICState bits (building on IC) |
| 701 // ExtraICState bits | 684 // ExtraICState bits |
| 702 class ExtraICStateKeyedAccessStoreMode: | 685 class ExtraICStateKeyedAccessStoreMode: |
| 703 public BitField<KeyedAccessStoreMode, 1, 4> {}; // NOLINT | 686 public BitField<KeyedAccessStoreMode, 2, 4> {}; // NOLINT |
| 704 | 687 |
| 705 static ExtraICState ComputeExtraICState(StrictModeFlag flag, | 688 static ExtraICState ComputeExtraICState(StrictModeFlag flag, |
| 706 KeyedAccessStoreMode mode) { | 689 KeyedAccessStoreMode mode) { |
| 707 return StrictModeState::encode(flag) | | 690 return StrictModeState::encode(flag) | |
| 708 ExtraICStateKeyedAccessStoreMode::encode(mode); | 691 ExtraICStateKeyedAccessStoreMode::encode(mode); |
| 709 } | 692 } |
| 710 | 693 |
| 711 static KeyedAccessStoreMode GetKeyedAccessStoreMode( | 694 static KeyedAccessStoreMode GetKeyedAccessStoreMode( |
| 712 ExtraICState extra_state) { | 695 ExtraICState extra_state) { |
| 713 return ExtraICStateKeyedAccessStoreMode::decode(extra_state); | 696 return ExtraICStateKeyedAccessStoreMode::decode(extra_state); |
| 714 } | 697 } |
| 715 | 698 |
| 716 KeyedStoreIC(FrameDepth depth, Isolate* isolate) | 699 KeyedStoreIC(FrameDepth depth, Isolate* isolate) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 732 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 715 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 733 StrictModeFlag strict_mode); | 716 StrictModeFlag strict_mode); |
| 734 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); | 717 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); |
| 735 static void GenerateNonStrictArguments(MacroAssembler* masm); | 718 static void GenerateNonStrictArguments(MacroAssembler* masm); |
| 736 | 719 |
| 737 protected: | 720 protected: |
| 738 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } | 721 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } |
| 739 | 722 |
| 740 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } | 723 virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { } |
| 741 | 724 |
| 742 virtual ExtraICState extra_ic_state() { | |
| 743 return ComputeExtraICState(strict_mode(), STANDARD_STORE); | |
| 744 } | |
| 745 | |
| 746 virtual Handle<Code> pre_monomorphic_stub() { | 725 virtual Handle<Code> pre_monomorphic_stub() { |
| 747 return pre_monomorphic_stub(isolate(), strict_mode()); | 726 return pre_monomorphic_stub(isolate(), strict_mode()); |
| 748 } | 727 } |
| 749 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 728 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
| 750 StrictModeFlag strict_mode) { | 729 StrictModeFlag strict_mode) { |
| 751 if (strict_mode == kStrictMode) { | 730 if (strict_mode == kStrictMode) { |
| 752 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); | 731 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); |
| 753 } else { | 732 } else { |
| 754 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); | 733 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); |
| 755 } | 734 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 769 KeyedAccessStoreMode store_mode); | 748 KeyedAccessStoreMode store_mode); |
| 770 | 749 |
| 771 private: | 750 private: |
| 772 void set_target(Code* code) { | 751 void set_target(Code* code) { |
| 773 // Strict mode must be preserved across IC patching. | 752 // Strict mode must be preserved across IC patching. |
| 774 ASSERT(GetStrictMode(code->extra_ic_state()) == strict_mode()); | 753 ASSERT(GetStrictMode(code->extra_ic_state()) == strict_mode()); |
| 775 IC::set_target(code); | 754 IC::set_target(code); |
| 776 } | 755 } |
| 777 | 756 |
| 778 // Stub accessors. | 757 // Stub accessors. |
| 779 static Handle<Code> initialize_stub(Isolate* isolate, | |
| 780 StrictModeFlag strict_mode) { | |
| 781 if (strict_mode == kStrictMode) { | |
| 782 return isolate->builtins()->KeyedStoreIC_Initialize_Strict(); | |
| 783 } else { | |
| 784 return isolate->builtins()->KeyedStoreIC_Initialize(); | |
| 785 } | |
| 786 } | |
| 787 | |
| 788 virtual Handle<Code> generic_stub() const { | 758 virtual Handle<Code> generic_stub() const { |
| 789 if (strict_mode() == kStrictMode) { | 759 if (strict_mode() == kStrictMode) { |
| 790 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | 760 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
| 791 } else { | 761 } else { |
| 792 return isolate()->builtins()->KeyedStoreIC_Generic(); | 762 return isolate()->builtins()->KeyedStoreIC_Generic(); |
| 793 } | 763 } |
| 794 } | 764 } |
| 795 | 765 |
| 796 Handle<Code> non_strict_arguments_stub() { | 766 Handle<Code> non_strict_arguments_stub() { |
| 797 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); | 767 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure); | 998 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure); |
| 1029 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); | 999 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); |
| 1030 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); | 1000 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); |
| 1031 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 1001 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
| 1032 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 1002 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
| 1033 | 1003 |
| 1034 | 1004 |
| 1035 } } // namespace v8::internal | 1005 } } // namespace v8::internal |
| 1036 | 1006 |
| 1037 #endif // V8_IC_H_ | 1007 #endif // V8_IC_H_ |
| OLD | NEW |