| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 ICU(KeyedStoreIC_Miss) \ | 50 ICU(KeyedStoreIC_Miss) \ |
| 51 ICU(KeyedStoreIC_MissForceGeneric) \ | 51 ICU(KeyedStoreIC_MissForceGeneric) \ |
| 52 ICU(KeyedStoreIC_Slow) \ | 52 ICU(KeyedStoreIC_Slow) \ |
| 53 /* Utilities for IC stubs. */ \ | 53 /* Utilities for IC stubs. */ \ |
| 54 ICU(StoreCallbackProperty) \ | 54 ICU(StoreCallbackProperty) \ |
| 55 ICU(LoadPropertyWithInterceptorOnly) \ | 55 ICU(LoadPropertyWithInterceptorOnly) \ |
| 56 ICU(LoadPropertyWithInterceptorForLoad) \ | 56 ICU(LoadPropertyWithInterceptorForLoad) \ |
| 57 ICU(LoadPropertyWithInterceptorForCall) \ | 57 ICU(LoadPropertyWithInterceptorForCall) \ |
| 58 ICU(KeyedLoadPropertyWithInterceptor) \ | 58 ICU(KeyedLoadPropertyWithInterceptor) \ |
| 59 ICU(StoreInterceptorProperty) \ | 59 ICU(StoreInterceptorProperty) \ |
| 60 ICU(BinaryOp_Patch) \ | |
| 61 ICU(CompareIC_Miss) \ | 60 ICU(CompareIC_Miss) \ |
| 61 ICU(BinaryOpIC_Miss) \ |
| 62 ICU(CompareNilIC_Miss) \ | 62 ICU(CompareNilIC_Miss) \ |
| 63 ICU(Unreachable) \ | 63 ICU(Unreachable) \ |
| 64 ICU(ToBooleanIC_Miss) | 64 ICU(ToBooleanIC_Miss) |
| 65 // | 65 // |
| 66 // IC is the base class for LoadIC, StoreIC, CallIC, KeyedLoadIC, | 66 // IC is the base class for LoadIC, StoreIC, CallIC, KeyedLoadIC, |
| 67 // and KeyedStoreIC. | 67 // and KeyedStoreIC. |
| 68 // | 68 // |
| 69 class IC { | 69 class IC { |
| 70 public: | 70 public: |
| 71 // The ids for utility called from the generated code. | 71 // The ids for utility called from the generated code. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 88 NO_EXTRA_FRAME = 0, | 88 NO_EXTRA_FRAME = 0, |
| 89 EXTRA_CALL_FRAME = 1 | 89 EXTRA_CALL_FRAME = 1 |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 // Construct the IC structure with the given number of extra | 92 // Construct the IC structure with the given number of extra |
| 93 // JavaScript frames on the stack. | 93 // JavaScript frames on the stack. |
| 94 IC(FrameDepth depth, Isolate* isolate); | 94 IC(FrameDepth depth, Isolate* isolate); |
| 95 virtual ~IC() {} | 95 virtual ~IC() {} |
| 96 | 96 |
| 97 // Get the call-site target; used for determining the state. | 97 // Get the call-site target; used for determining the state. |
| 98 Code* target() const { return GetTargetAtAddress(address()); } | 98 Handle<Code> target() const { return target_; } |
| 99 Code* raw_target() const { return GetTargetAtAddress(address()); } |
| 100 |
| 101 State state() const { return state_; } |
| 99 inline Address address() const; | 102 inline Address address() const; |
| 100 | 103 |
| 101 // Compute the current IC state based on the target stub, receiver and name. | 104 // Compute the current IC state based on the target stub, receiver and name. |
| 102 static State StateFrom(Code* target, Object* receiver, Object* name); | 105 void UpdateState(Handle<Object> receiver, Handle<Object> name); |
| 106 void MarkMonomorphicPrototypeFailure() { |
| 107 state_ = MONOMORPHIC_PROTOTYPE_FAILURE; |
| 108 } |
| 103 | 109 |
| 104 // Clear the inline cache to initial state. | 110 // Clear the inline cache to initial state. |
| 105 static void Clear(Isolate* isolate, Address address); | 111 static void Clear(Isolate* isolate, Address address); |
| 106 | 112 |
| 107 // Computes the reloc info for this IC. This is a fairly expensive | 113 // 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 | 114 // operation as it has to search through the heap to find the code |
| 109 // object that contains this IC site. | 115 // object that contains this IC site. |
| 110 RelocInfo::Mode ComputeMode(); | 116 RelocInfo::Mode ComputeMode(); |
| 111 | 117 |
| 112 // Returns if this IC is for contextual (no explicit receiver) | 118 // Returns if this IC is for contextual (no explicit receiver) |
| 113 // access to properties. | 119 // access to properties. |
| 114 bool IsUndeclaredGlobal(Handle<Object> receiver) { | 120 bool IsUndeclaredGlobal(Handle<Object> receiver) { |
| 115 if (receiver->IsGlobalObject()) { | 121 if (receiver->IsGlobalObject()) { |
| 116 return SlowIsUndeclaredGlobal(); | 122 return SlowIsUndeclaredGlobal(); |
| 117 } else { | 123 } else { |
| 118 ASSERT(!SlowIsUndeclaredGlobal()); | 124 ASSERT(!SlowIsUndeclaredGlobal()); |
| 119 return false; | 125 return false; |
| 120 } | 126 } |
| 121 } | 127 } |
| 122 | 128 |
| 123 bool SlowIsUndeclaredGlobal() { | 129 bool SlowIsUndeclaredGlobal() { |
| 124 return ComputeMode() == RelocInfo::CODE_TARGET_CONTEXT; | 130 return ComputeMode() == RelocInfo::CODE_TARGET_CONTEXT; |
| 125 } | 131 } |
| 126 | 132 |
| 127 // Determines which map must be used for keeping the code stub. | 133 // Determines which map must be used for keeping the code stub. |
| 128 // These methods should not be called with undefined or null. | 134 // These methods should not be called with undefined or null. |
| 129 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object, | 135 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object, |
| 130 JSObject* holder); | 136 JSObject* holder); |
| 131 static inline InlineCacheHolderFlag GetCodeCacheForObject(JSObject* object, | |
| 132 JSObject* holder); | |
| 133 static inline JSObject* GetCodeCacheHolder(Isolate* isolate, | 137 static inline JSObject* GetCodeCacheHolder(Isolate* isolate, |
| 134 Object* object, | 138 Object* object, |
| 135 InlineCacheHolderFlag holder); | 139 InlineCacheHolderFlag holder); |
| 136 | 140 |
| 137 static bool IsCleared(Code* code) { | 141 static bool IsCleared(Code* code) { |
| 138 InlineCacheState state = code->ic_state(); | 142 InlineCacheState state = code->ic_state(); |
| 139 return state == UNINITIALIZED || state == PREMONOMORPHIC; | 143 return state == UNINITIALIZED || state == PREMONOMORPHIC; |
| 140 } | 144 } |
| 141 | 145 |
| 142 protected: | 146 protected: |
| 143 Address fp() const { return fp_; } | 147 Address fp() const { return fp_; } |
| 144 Address pc() const { return *pc_address_; } | 148 Address pc() const { return *pc_address_; } |
| 145 Isolate* isolate() const { return isolate_; } | 149 Isolate* isolate() const { return isolate_; } |
| 146 | 150 |
| 147 #ifdef ENABLE_DEBUGGER_SUPPORT | 151 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 148 // Computes the address in the original code when the code running is | 152 // Computes the address in the original code when the code running is |
| 149 // containing break points (calls to DebugBreakXXX builtins). | 153 // containing break points (calls to DebugBreakXXX builtins). |
| 150 Address OriginalCodeAddress() const; | 154 Address OriginalCodeAddress() const; |
| 151 #endif | 155 #endif |
| 152 | 156 |
| 153 // Set the call-site target. | 157 // Set the call-site target. |
| 154 void set_target(Code* code) { SetTargetAtAddress(address(), code); } | 158 void set_target(Code* code) { SetTargetAtAddress(address(), code); } |
| 155 | 159 |
| 156 #ifdef DEBUG | 160 #ifdef DEBUG |
| 157 char TransitionMarkFromState(IC::State state); | 161 char TransitionMarkFromState(IC::State state); |
| 158 | 162 |
| 159 void TraceIC(const char* type, | 163 void TraceIC(const char* type, Handle<Object> name); |
| 160 Handle<Object> name, | |
| 161 State old_state, | |
| 162 Code* new_target); | |
| 163 #endif | 164 #endif |
| 164 | 165 |
| 165 Failure* TypeError(const char* type, | 166 Failure* TypeError(const char* type, |
| 166 Handle<Object> object, | 167 Handle<Object> object, |
| 167 Handle<Object> key); | 168 Handle<Object> key); |
| 168 Failure* ReferenceError(const char* type, Handle<String> name); | 169 Failure* ReferenceError(const char* type, Handle<String> name); |
| 169 | 170 |
| 170 // Access the target code for the given IC address. | 171 // Access the target code for the given IC address. |
| 171 static inline Code* GetTargetAtAddress(Address address); | 172 static inline Code* GetTargetAtAddress(Address address); |
| 172 static inline void SetTargetAtAddress(Address address, Code* target); | 173 static inline void SetTargetAtAddress(Address address, Code* target); |
| 173 static void PostPatching(Address address, Code* target, Code* old_target); | 174 static void PostPatching(Address address, Code* target, Code* old_target); |
| 174 | 175 |
| 175 virtual void UpdateMonomorphicIC(Handle<HeapObject> receiver, | 176 void UpdateMonomorphicIC(Handle<HeapObject> receiver, |
| 176 Handle<Code> handler, | 177 Handle<Code> handler, |
| 177 Handle<String> name, | 178 Handle<String> name); |
| 178 StrictModeFlag strict_mode) { | 179 |
| 179 set_target(*handler); | 180 bool UpdatePolymorphicIC(Handle<HeapObject> receiver, |
| 180 } | |
| 181 bool UpdatePolymorphicIC(State state, | |
| 182 Handle<HeapObject> receiver, | |
| 183 Handle<String> name, | 181 Handle<String> name, |
| 184 Handle<Code> code, | 182 Handle<Code> code); |
| 185 StrictModeFlag strict_mode); | |
| 186 | |
| 187 virtual Handle<Code> ComputePolymorphicIC(MapHandleList* receiver_maps, | |
| 188 CodeHandleList* handlers, | |
| 189 int number_of_valid_maps, | |
| 190 Handle<Name> name, | |
| 191 StrictModeFlag strict_mode) { | |
| 192 UNREACHABLE(); | |
| 193 return Handle<Code>::null(); | |
| 194 }; | |
| 195 | 183 |
| 196 void CopyICToMegamorphicCache(Handle<String> name); | 184 void CopyICToMegamorphicCache(Handle<String> name); |
| 197 bool IsTransitionedMapOfMonomorphicTarget(Map* receiver_map); | 185 bool IsTransitionedMapOfMonomorphicTarget(Map* receiver_map); |
| 198 void PatchCache(State state, | 186 void PatchCache(Handle<HeapObject> receiver, |
| 199 StrictModeFlag strict_mode, | |
| 200 Handle<HeapObject> receiver, | |
| 201 Handle<String> name, | 187 Handle<String> name, |
| 202 Handle<Code> code); | 188 Handle<Code> code); |
| 203 virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code); | 189 virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code); |
| 204 virtual Handle<Code> megamorphic_stub() { | 190 virtual Handle<Code> megamorphic_stub() { |
| 205 UNREACHABLE(); | 191 UNREACHABLE(); |
| 206 return Handle<Code>::null(); | 192 return Handle<Code>::null(); |
| 207 } | 193 } |
| 208 virtual Handle<Code> megamorphic_stub_strict() { | |
| 209 UNREACHABLE(); | |
| 210 return Handle<Code>::null(); | |
| 211 } | |
| 212 virtual Handle<Code> generic_stub() const { | 194 virtual Handle<Code> generic_stub() const { |
| 213 UNREACHABLE(); | 195 UNREACHABLE(); |
| 214 return Handle<Code>::null(); | 196 return Handle<Code>::null(); |
| 215 } | 197 } |
| 216 virtual Handle<Code> generic_stub_strict() const { | 198 virtual StrictModeFlag strict_mode() const { return kNonStrictMode; } |
| 217 UNREACHABLE(); | 199 bool TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, |
| 218 return Handle<Code>::null(); | 200 Handle<String> name); |
| 219 } | |
| 220 | 201 |
| 221 private: | 202 private: |
| 222 // Frame pointer for the frame that uses (calls) the IC. | 203 // Frame pointer for the frame that uses (calls) the IC. |
| 223 Address fp_; | 204 Address fp_; |
| 224 | 205 |
| 225 // All access to the program counter of an IC structure is indirect | 206 // All access to the program counter of an IC structure is indirect |
| 226 // to make the code GC safe. This feature is crucial since | 207 // to make the code GC safe. This feature is crucial since |
| 227 // GetProperty and SetProperty are called and they in turn might | 208 // GetProperty and SetProperty are called and they in turn might |
| 228 // invoke the garbage collector. | 209 // invoke the garbage collector. |
| 229 Address* pc_address_; | 210 Address* pc_address_; |
| 230 | 211 |
| 231 Isolate* isolate_; | 212 Isolate* isolate_; |
| 232 | 213 |
| 214 // The original code target that missed. |
| 215 Handle<Code> target_; |
| 216 State state_; |
| 217 |
| 233 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); | 218 DISALLOW_IMPLICIT_CONSTRUCTORS(IC); |
| 234 }; | 219 }; |
| 235 | 220 |
| 236 | 221 |
| 237 // An IC_Utility encapsulates IC::UtilityId. It exists mainly because you | 222 // An IC_Utility encapsulates IC::UtilityId. It exists mainly because you |
| 238 // cannot make forward declarations to an enum. | 223 // cannot make forward declarations to an enum. |
| 239 class IC_Utility { | 224 class IC_Utility { |
| 240 public: | 225 public: |
| 241 explicit IC_Utility(IC::UtilityId id) | 226 explicit IC_Utility(IC::UtilityId id) |
| 242 : address_(IC::AddressFromUtilityId(id)), id_(id) {} | 227 : address_(IC::AddressFromUtilityId(id)), id_(id) {} |
| 243 | 228 |
| 244 Address address() const { return address_; } | 229 Address address() const { return address_; } |
| 245 | 230 |
| 246 IC::UtilityId id() const { return id_; } | 231 IC::UtilityId id() const { return id_; } |
| 247 private: | 232 private: |
| 248 Address address_; | 233 Address address_; |
| 249 IC::UtilityId id_; | 234 IC::UtilityId id_; |
| 250 }; | 235 }; |
| 251 | 236 |
| 252 | 237 |
| 253 class CallICBase: public IC { | 238 class CallICBase: public IC { |
| 254 public: | 239 public: |
| 255 class Contextual: public BitField<bool, 0, 1> {}; | 240 class Contextual: public BitField<bool, 0, 1> {}; |
| 256 class StringStubState: public BitField<StringStubFeedback, 1, 1> {}; | 241 class StringStubState: public BitField<StringStubFeedback, 1, 1> {}; |
| 257 | 242 |
| 258 // Returns a JSFunction or a Failure. | 243 // Returns a JSFunction or a Failure. |
| 259 MUST_USE_RESULT MaybeObject* LoadFunction(State state, | 244 MUST_USE_RESULT MaybeObject* LoadFunction(Handle<Object> object, |
| 260 Code::ExtraICState extra_ic_state, | |
| 261 Handle<Object> object, | |
| 262 Handle<String> name); | 245 Handle<String> name); |
| 263 | 246 |
| 264 protected: | 247 protected: |
| 265 CallICBase(Code::Kind kind, Isolate* isolate) | 248 CallICBase(Code::Kind kind, Isolate* isolate) |
| 266 : IC(EXTRA_CALL_FRAME, isolate), kind_(kind) {} | 249 : IC(EXTRA_CALL_FRAME, isolate), kind_(kind) {} |
| 267 | 250 |
| 268 bool TryUpdateExtraICState(LookupResult* lookup, | 251 virtual Code::ExtraICState extra_ic_state() { return Code::kNoExtraICState; } |
| 269 Handle<Object> object, | |
| 270 Code::ExtraICState* extra_ic_state); | |
| 271 | 252 |
| 272 // Compute a monomorphic stub if possible, otherwise return a null handle. | 253 // Compute a monomorphic stub if possible, otherwise return a null handle. |
| 273 Handle<Code> ComputeMonomorphicStub(LookupResult* lookup, | 254 Handle<Code> ComputeMonomorphicStub(LookupResult* lookup, |
| 274 State state, | |
| 275 Code::ExtraICState extra_state, | |
| 276 Handle<Object> object, | 255 Handle<Object> object, |
| 277 Handle<String> name); | 256 Handle<String> name); |
| 278 | 257 |
| 279 // Update the inline cache and the global stub cache based on the lookup | 258 // Update the inline cache and the global stub cache based on the lookup |
| 280 // result. | 259 // result. |
| 281 void UpdateCaches(LookupResult* lookup, | 260 void UpdateCaches(LookupResult* lookup, |
| 282 State state, | |
| 283 Code::ExtraICState extra_ic_state, | |
| 284 Handle<Object> object, | 261 Handle<Object> object, |
| 285 Handle<String> name); | 262 Handle<String> name); |
| 286 | 263 |
| 287 // Returns a JSFunction if the object can be called as a function, and | 264 // Returns a JSFunction if the object can be called as a function, and |
| 288 // patches the stack to be ready for the call. Otherwise, it returns the | 265 // patches the stack to be ready for the call. Otherwise, it returns the |
| 289 // undefined value. | 266 // undefined value. |
| 290 Handle<Object> TryCallAsFunction(Handle<Object> object); | 267 Handle<Object> TryCallAsFunction(Handle<Object> object); |
| 291 | 268 |
| 292 void ReceiverToObjectIfRequired(Handle<Object> callee, Handle<Object> object); | 269 void ReceiverToObjectIfRequired(Handle<Object> callee, Handle<Object> object); |
| 293 | 270 |
| 294 static void Clear(Address address, Code* target); | 271 static void Clear(Address address, Code* target); |
| 295 | 272 |
| 296 // Platform-specific code generation functions used by both call and | 273 // Platform-specific code generation functions used by both call and |
| 297 // keyed call. | 274 // keyed call. |
| 298 static void GenerateMiss(MacroAssembler* masm, | 275 static void GenerateMiss(MacroAssembler* masm, |
| 299 int argc, | 276 int argc, |
| 300 IC::UtilityId id, | 277 IC::UtilityId id, |
| 301 Code::ExtraICState extra_state); | 278 Code::ExtraICState extra_state); |
| 302 | 279 |
| 303 static void GenerateNormal(MacroAssembler* masm, int argc); | 280 static void GenerateNormal(MacroAssembler* masm, int argc); |
| 304 | 281 |
| 305 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, | 282 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, |
| 306 int argc, | 283 int argc, |
| 307 Code::Kind kind, | 284 Code::Kind kind, |
| 308 Code::ExtraICState extra_state); | 285 Code::ExtraICState extra_state); |
| 309 | 286 |
| 287 virtual Handle<Code> megamorphic_stub(); |
| 288 virtual Handle<Code> pre_monomorphic_stub(); |
| 289 |
| 310 Code::Kind kind_; | 290 Code::Kind kind_; |
| 311 | 291 |
| 312 friend class IC; | 292 friend class IC; |
| 313 }; | 293 }; |
| 314 | 294 |
| 315 | 295 |
| 316 class CallIC: public CallICBase { | 296 class CallIC: public CallICBase { |
| 317 public: | 297 public: |
| 318 explicit CallIC(Isolate* isolate) : CallICBase(Code::CALL_IC, isolate) { | 298 explicit CallIC(Isolate* isolate) |
| 299 : CallICBase(Code::CALL_IC, isolate), |
| 300 extra_ic_state_(target()->extra_ic_state()) { |
| 319 ASSERT(target()->is_call_stub()); | 301 ASSERT(target()->is_call_stub()); |
| 320 } | 302 } |
| 321 | 303 |
| 322 // Code generator routines. | 304 // Code generator routines. |
| 323 static void GenerateInitialize(MacroAssembler* masm, | 305 static void GenerateInitialize(MacroAssembler* masm, |
| 324 int argc, | 306 int argc, |
| 325 Code::ExtraICState extra_state) { | 307 Code::ExtraICState extra_state) { |
| 326 GenerateMiss(masm, argc, extra_state); | 308 GenerateMiss(masm, argc, extra_state); |
| 327 } | 309 } |
| 328 | 310 |
| 329 static void GenerateMiss(MacroAssembler* masm, | 311 static void GenerateMiss(MacroAssembler* masm, |
| 330 int argc, | 312 int argc, |
| 331 Code::ExtraICState extra_state) { | 313 Code::ExtraICState extra_state) { |
| 332 CallICBase::GenerateMiss(masm, argc, IC::kCallIC_Miss, extra_state); | 314 CallICBase::GenerateMiss(masm, argc, IC::kCallIC_Miss, extra_state); |
| 333 } | 315 } |
| 334 | 316 |
| 335 static void GenerateMegamorphic(MacroAssembler* masm, | 317 static void GenerateMegamorphic(MacroAssembler* masm, |
| 336 int argc, | 318 int argc, |
| 337 Code::ExtraICState extra_ic_state); | 319 Code::ExtraICState extra_ic_state); |
| 338 | 320 |
| 339 static void GenerateNormal(MacroAssembler* masm, int argc) { | 321 static void GenerateNormal(MacroAssembler* masm, int argc) { |
| 340 CallICBase::GenerateNormal(masm, argc); | 322 CallICBase::GenerateNormal(masm, argc); |
| 341 GenerateMiss(masm, argc, Code::kNoExtraICState); | 323 GenerateMiss(masm, argc, Code::kNoExtraICState); |
| 342 } | 324 } |
| 325 bool TryUpdateExtraICState(LookupResult* lookup, Handle<Object> object); |
| 326 |
| 327 protected: |
| 328 virtual Code::ExtraICState extra_ic_state() { return extra_ic_state_; } |
| 329 |
| 330 private: |
| 331 Code::ExtraICState extra_ic_state_; |
| 343 }; | 332 }; |
| 344 | 333 |
| 345 | 334 |
| 346 class KeyedCallIC: public CallICBase { | 335 class KeyedCallIC: public CallICBase { |
| 347 public: | 336 public: |
| 348 explicit KeyedCallIC(Isolate* isolate) | 337 explicit KeyedCallIC(Isolate* isolate) |
| 349 : CallICBase(Code::KEYED_CALL_IC, isolate) { | 338 : CallICBase(Code::KEYED_CALL_IC, isolate) { |
| 350 ASSERT(target()->is_keyed_call_stub()); | 339 ASSERT(target()->is_keyed_call_stub()); |
| 351 } | 340 } |
| 352 | 341 |
| 353 MUST_USE_RESULT MaybeObject* LoadFunction(State state, | 342 MUST_USE_RESULT MaybeObject* LoadFunction(Handle<Object> object, |
| 354 Handle<Object> object, | |
| 355 Handle<Object> key); | 343 Handle<Object> key); |
| 356 | 344 |
| 357 // Code generator routines. | 345 // Code generator routines. |
| 358 static void GenerateInitialize(MacroAssembler* masm, int argc) { | 346 static void GenerateInitialize(MacroAssembler* masm, int argc) { |
| 359 GenerateMiss(masm, argc); | 347 GenerateMiss(masm, argc); |
| 360 } | 348 } |
| 361 | 349 |
| 362 static void GenerateMiss(MacroAssembler* masm, int argc) { | 350 static void GenerateMiss(MacroAssembler* masm, int argc) { |
| 363 CallICBase::GenerateMiss(masm, argc, IC::kKeyedCallIC_Miss, | 351 CallICBase::GenerateMiss(masm, argc, IC::kKeyedCallIC_Miss, |
| 364 Code::kNoExtraICState); | 352 Code::kNoExtraICState); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 379 // Code generator routines. | 367 // Code generator routines. |
| 380 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 368 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 381 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 369 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 382 GenerateMiss(masm); | 370 GenerateMiss(masm); |
| 383 } | 371 } |
| 384 static void GenerateMiss(MacroAssembler* masm); | 372 static void GenerateMiss(MacroAssembler* masm); |
| 385 static void GenerateMegamorphic(MacroAssembler* masm); | 373 static void GenerateMegamorphic(MacroAssembler* masm); |
| 386 static void GenerateNormal(MacroAssembler* masm); | 374 static void GenerateNormal(MacroAssembler* masm); |
| 387 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 375 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
| 388 | 376 |
| 389 MUST_USE_RESULT MaybeObject* Load(State state, | 377 MUST_USE_RESULT MaybeObject* Load(Handle<Object> object, |
| 390 Handle<Object> object, | |
| 391 Handle<String> name); | 378 Handle<String> name); |
| 392 | 379 |
| 393 protected: | 380 protected: |
| 394 virtual Code::Kind kind() const { return Code::LOAD_IC; } | 381 virtual Code::Kind kind() const { return Code::LOAD_IC; } |
| 395 | 382 |
| 396 virtual Handle<Code> slow_stub() const { | 383 virtual Handle<Code> slow_stub() const { |
| 397 return isolate()->builtins()->LoadIC_Slow(); | 384 return isolate()->builtins()->LoadIC_Slow(); |
| 398 } | 385 } |
| 399 | 386 |
| 400 virtual Handle<Code> megamorphic_stub() { | 387 virtual Handle<Code> megamorphic_stub() { |
| 401 return isolate()->builtins()->LoadIC_Megamorphic(); | 388 return isolate()->builtins()->LoadIC_Megamorphic(); |
| 402 } | 389 } |
| 403 | 390 |
| 404 // Update the inline cache and the global stub cache based on the | 391 // Update the inline cache and the global stub cache based on the |
| 405 // lookup result. | 392 // lookup result. |
| 406 void UpdateCaches(LookupResult* lookup, | 393 void UpdateCaches(LookupResult* lookup, |
| 407 State state, | |
| 408 Handle<Object> object, | 394 Handle<Object> object, |
| 409 Handle<String> name); | 395 Handle<String> name); |
| 410 | 396 |
| 411 virtual void UpdateMonomorphicIC(Handle<HeapObject> receiver, | |
| 412 Handle<Code> handler, | |
| 413 Handle<String> name, | |
| 414 StrictModeFlag strict_mode); | |
| 415 | |
| 416 virtual Handle<Code> ComputePolymorphicIC(MapHandleList* receiver_maps, | |
| 417 CodeHandleList* handlers, | |
| 418 int number_of_valid_maps, | |
| 419 Handle<Name> name, | |
| 420 StrictModeFlag strict_mode); | |
| 421 | |
| 422 virtual Handle<Code> ComputeLoadHandler(LookupResult* lookup, | 397 virtual Handle<Code> ComputeLoadHandler(LookupResult* lookup, |
| 423 Handle<JSObject> receiver, | 398 Handle<JSObject> receiver, |
| 424 Handle<String> name); | 399 Handle<String> name); |
| 425 | 400 |
| 426 private: | 401 private: |
| 427 // Stub accessors. | 402 // Stub accessors. |
| 428 static Handle<Code> initialize_stub(Isolate* isolate) { | 403 static Handle<Code> initialize_stub(Isolate* isolate) { |
| 429 return isolate->builtins()->LoadIC_Initialize(); | 404 return isolate->builtins()->LoadIC_Initialize(); |
| 430 } | 405 } |
| 406 |
| 431 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { | 407 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { |
| 432 return isolate->builtins()->LoadIC_PreMonomorphic(); | 408 return isolate->builtins()->LoadIC_PreMonomorphic(); |
| 433 } | 409 } |
| 410 |
| 434 virtual Handle<Code> pre_monomorphic_stub() { | 411 virtual Handle<Code> pre_monomorphic_stub() { |
| 435 return pre_monomorphic_stub(isolate()); | 412 return pre_monomorphic_stub(isolate()); |
| 436 } | 413 } |
| 437 | 414 |
| 438 static void Clear(Isolate* isolate, Address address, Code* target); | 415 static void Clear(Isolate* isolate, Address address, Code* target); |
| 439 | 416 |
| 440 friend class IC; | 417 friend class IC; |
| 441 }; | 418 }; |
| 442 | 419 |
| 443 | 420 |
| 444 enum ICMissMode { | 421 enum ICMissMode { |
| 445 MISS_FORCE_GENERIC, | 422 MISS_FORCE_GENERIC, |
| 446 MISS | 423 MISS |
| 447 }; | 424 }; |
| 448 | 425 |
| 449 | 426 |
| 450 class KeyedLoadIC: public LoadIC { | 427 class KeyedLoadIC: public LoadIC { |
| 451 public: | 428 public: |
| 452 explicit KeyedLoadIC(FrameDepth depth, Isolate* isolate) | 429 explicit KeyedLoadIC(FrameDepth depth, Isolate* isolate) |
| 453 : LoadIC(depth, isolate) { | 430 : LoadIC(depth, isolate) { |
| 454 ASSERT(target()->is_keyed_load_stub()); | 431 ASSERT(target()->is_keyed_load_stub()); |
| 455 } | 432 } |
| 456 | 433 |
| 457 MUST_USE_RESULT MaybeObject* Load(State state, | 434 MUST_USE_RESULT MaybeObject* Load(Handle<Object> object, |
| 458 Handle<Object> object, | |
| 459 Handle<Object> key, | 435 Handle<Object> key, |
| 460 ICMissMode force_generic); | 436 ICMissMode force_generic); |
| 461 | 437 |
| 462 // Code generator routines. | 438 // Code generator routines. |
| 463 static void GenerateMiss(MacroAssembler* masm, ICMissMode force_generic); | 439 static void GenerateMiss(MacroAssembler* masm, ICMissMode force_generic); |
| 464 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 440 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
| 465 static void GenerateInitialize(MacroAssembler* masm) { | 441 static void GenerateInitialize(MacroAssembler* masm) { |
| 466 GenerateMiss(masm, MISS); | 442 GenerateMiss(masm, MISS); |
| 467 } | 443 } |
| 468 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 444 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 489 return isolate()->builtins()->KeyedLoadIC_Generic(); | 465 return isolate()->builtins()->KeyedLoadIC_Generic(); |
| 490 } | 466 } |
| 491 virtual Handle<Code> generic_stub() const { | 467 virtual Handle<Code> generic_stub() const { |
| 492 return isolate()->builtins()->KeyedLoadIC_Generic(); | 468 return isolate()->builtins()->KeyedLoadIC_Generic(); |
| 493 } | 469 } |
| 494 virtual Handle<Code> slow_stub() const { | 470 virtual Handle<Code> slow_stub() const { |
| 495 return isolate()->builtins()->KeyedLoadIC_Slow(); | 471 return isolate()->builtins()->KeyedLoadIC_Slow(); |
| 496 } | 472 } |
| 497 | 473 |
| 498 // Update the inline cache. | 474 // Update the inline cache. |
| 499 virtual void UpdateMonomorphicIC(Handle<HeapObject> receiver, | |
| 500 Handle<Code> handler, | |
| 501 Handle<String> name, | |
| 502 StrictModeFlag strict_mode); | |
| 503 virtual Handle<Code> ComputeLoadHandler(LookupResult* lookup, | 475 virtual Handle<Code> ComputeLoadHandler(LookupResult* lookup, |
| 504 Handle<JSObject> receiver, | 476 Handle<JSObject> receiver, |
| 505 Handle<String> name); | 477 Handle<String> name); |
| 506 virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code) { } | 478 virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code) { } |
| 507 | 479 |
| 508 private: | 480 private: |
| 509 // Stub accessors. | 481 // Stub accessors. |
| 510 static Handle<Code> initialize_stub(Isolate* isolate) { | 482 static Handle<Code> initialize_stub(Isolate* isolate) { |
| 511 return isolate->builtins()->KeyedLoadIC_Initialize(); | 483 return isolate->builtins()->KeyedLoadIC_Initialize(); |
| 512 } | 484 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 527 } | 499 } |
| 528 | 500 |
| 529 static void Clear(Isolate* isolate, Address address, Code* target); | 501 static void Clear(Isolate* isolate, Address address, Code* target); |
| 530 | 502 |
| 531 friend class IC; | 503 friend class IC; |
| 532 }; | 504 }; |
| 533 | 505 |
| 534 | 506 |
| 535 class StoreIC: public IC { | 507 class StoreIC: public IC { |
| 536 public: | 508 public: |
| 537 StoreIC(FrameDepth depth, Isolate* isolate) : IC(depth, isolate) { | 509 StoreIC(FrameDepth depth, Isolate* isolate) |
| 510 : IC(depth, isolate), |
| 511 strict_mode_(Code::GetStrictMode(target()->extra_ic_state())) { |
| 538 ASSERT(target()->is_store_stub() || target()->is_keyed_store_stub()); | 512 ASSERT(target()->is_store_stub() || target()->is_keyed_store_stub()); |
| 539 } | 513 } |
| 540 | 514 |
| 515 virtual StrictModeFlag strict_mode() const { return strict_mode_; } |
| 516 |
| 541 // Code generators for stub routines. Only called once at startup. | 517 // Code generators for stub routines. Only called once at startup. |
| 542 static void GenerateSlow(MacroAssembler* masm); | 518 static void GenerateSlow(MacroAssembler* masm); |
| 543 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 519 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 544 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 520 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 545 GenerateMiss(masm); | 521 GenerateMiss(masm); |
| 546 } | 522 } |
| 547 static void GenerateMiss(MacroAssembler* masm); | 523 static void GenerateMiss(MacroAssembler* masm); |
| 548 static void GenerateMegamorphic(MacroAssembler* masm, | 524 static void GenerateMegamorphic(MacroAssembler* masm, |
| 549 StrictModeFlag strict_mode); | 525 StrictModeFlag strict_mode); |
| 550 static void GenerateNormal(MacroAssembler* masm); | 526 static void GenerateNormal(MacroAssembler* masm); |
| 551 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 527 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 552 StrictModeFlag strict_mode); | 528 StrictModeFlag strict_mode); |
| 553 | 529 |
| 554 MUST_USE_RESULT MaybeObject* Store( | 530 MUST_USE_RESULT MaybeObject* Store( |
| 555 State state, | |
| 556 StrictModeFlag strict_mode, | |
| 557 Handle<Object> object, | 531 Handle<Object> object, |
| 558 Handle<String> name, | 532 Handle<String> name, |
| 559 Handle<Object> value, | 533 Handle<Object> value, |
| 560 JSReceiver::StoreFromKeyed store_mode = | 534 JSReceiver::StoreFromKeyed store_mode = |
| 561 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); | 535 JSReceiver::CERTAINLY_NOT_STORE_FROM_KEYED); |
| 562 | 536 |
| 563 protected: | 537 protected: |
| 564 virtual Code::Kind kind() const { return Code::STORE_IC; } | 538 virtual Code::Kind kind() const { return Code::STORE_IC; } |
| 565 virtual Handle<Code> megamorphic_stub() { | 539 virtual Handle<Code> megamorphic_stub() { |
| 566 return isolate()->builtins()->StoreIC_Megamorphic(); | 540 if (strict_mode() == kStrictMode) { |
| 541 return isolate()->builtins()->StoreIC_Megamorphic_Strict(); |
| 542 } else { |
| 543 return isolate()->builtins()->StoreIC_Megamorphic(); |
| 544 } |
| 567 } | 545 } |
| 568 // Stub accessors. | 546 // Stub accessors. |
| 569 virtual Handle<Code> megamorphic_stub_strict() { | |
| 570 return isolate()->builtins()->StoreIC_Megamorphic_Strict(); | |
| 571 } | |
| 572 virtual Handle<Code> generic_stub() const { | 547 virtual Handle<Code> generic_stub() const { |
| 573 return isolate()->builtins()->StoreIC_Generic(); | 548 if (strict_mode() == kStrictMode) { |
| 574 } | 549 return isolate()->builtins()->StoreIC_Generic_Strict(); |
| 575 virtual Handle<Code> generic_stub_strict() const { | 550 } else { |
| 576 return isolate()->builtins()->StoreIC_Generic_Strict(); | 551 return isolate()->builtins()->StoreIC_Generic(); |
| 577 } | 552 } |
| 578 virtual Handle<Code> pre_monomorphic_stub() { | |
| 579 return pre_monomorphic_stub(isolate()); | |
| 580 } | |
| 581 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { | |
| 582 return isolate->builtins()->StoreIC_PreMonomorphic(); | |
| 583 } | |
| 584 virtual Handle<Code> pre_monomorphic_stub_strict() { | |
| 585 return pre_monomorphic_stub_strict(isolate()); | |
| 586 } | |
| 587 static Handle<Code> pre_monomorphic_stub_strict(Isolate* isolate) { | |
| 588 return isolate->builtins()->StoreIC_PreMonomorphic_Strict(); | |
| 589 } | |
| 590 virtual Handle<Code> global_proxy_stub() { | |
| 591 return isolate()->builtins()->StoreIC_GlobalProxy(); | |
| 592 } | |
| 593 virtual Handle<Code> global_proxy_stub_strict() { | |
| 594 return isolate()->builtins()->StoreIC_GlobalProxy_Strict(); | |
| 595 } | 553 } |
| 596 | 554 |
| 597 virtual void UpdateMonomorphicIC(Handle<HeapObject> receiver, | 555 virtual Handle<Code> pre_monomorphic_stub() { |
| 598 Handle<Code> handler, | 556 return pre_monomorphic_stub(isolate(), strict_mode()); |
| 599 Handle<String> name, | 557 } |
| 600 StrictModeFlag strict_mode); | |
| 601 | 558 |
| 602 virtual Handle<Code> ComputePolymorphicIC(MapHandleList* receiver_maps, | 559 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
| 603 CodeHandleList* handlers, | 560 StrictModeFlag strict_mode) { |
| 604 int number_of_valid_maps, | 561 if (strict_mode == kStrictMode) { |
| 605 Handle<Name> name, | 562 return isolate->builtins()->StoreIC_PreMonomorphic_Strict(); |
| 606 StrictModeFlag strict_mode); | 563 } else { |
| 564 return isolate->builtins()->StoreIC_PreMonomorphic(); |
| 565 } |
| 566 } |
| 567 |
| 568 virtual Handle<Code> global_proxy_stub() { |
| 569 if (strict_mode() == kStrictMode) { |
| 570 return isolate()->builtins()->StoreIC_GlobalProxy_Strict(); |
| 571 } else { |
| 572 return isolate()->builtins()->StoreIC_GlobalProxy(); |
| 573 } |
| 574 } |
| 607 | 575 |
| 608 // Update the inline cache and the global stub cache based on the | 576 // Update the inline cache and the global stub cache based on the |
| 609 // lookup result. | 577 // lookup result. |
| 610 void UpdateCaches(LookupResult* lookup, | 578 void UpdateCaches(LookupResult* lookup, |
| 611 State state, | |
| 612 StrictModeFlag strict_mode, | |
| 613 Handle<JSObject> receiver, | 579 Handle<JSObject> receiver, |
| 614 Handle<String> name, | 580 Handle<String> name, |
| 615 Handle<Object> value); | 581 Handle<Object> value); |
| 616 // Compute the code stub for this store; used for rewriting to | 582 // Compute the code stub for this store; used for rewriting to |
| 617 // monomorphic state and making sure that the code stub is in the | 583 // monomorphic state and making sure that the code stub is in the |
| 618 // stub cache. | 584 // stub cache. |
| 619 virtual Handle<Code> ComputeStoreMonomorphic(LookupResult* lookup, | 585 virtual Handle<Code> ComputeStoreHandler(LookupResult* lookup, |
| 620 StrictModeFlag strict_mode, | 586 Handle<JSObject> receiver, |
| 621 Handle<JSObject> receiver, | 587 Handle<String> name, |
| 622 Handle<String> name, | 588 Handle<Object> value); |
| 623 Handle<Object> value); | |
| 624 | 589 |
| 625 private: | 590 private: |
| 626 void set_target(Code* code) { | 591 void set_target(Code* code) { |
| 627 // Strict mode must be preserved across IC patching. | 592 // Strict mode must be preserved across IC patching. |
| 628 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == | 593 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == |
| 629 Code::GetStrictMode(target()->extra_ic_state())); | 594 Code::GetStrictMode(target()->extra_ic_state())); |
| 630 IC::set_target(code); | 595 IC::set_target(code); |
| 631 } | 596 } |
| 632 | 597 |
| 633 static Handle<Code> initialize_stub(Isolate* isolate) { | 598 static Handle<Code> initialize_stub(Isolate* isolate, |
| 634 return isolate->builtins()->StoreIC_Initialize(); | 599 StrictModeFlag strict_mode) { |
| 600 if (strict_mode == kStrictMode) { |
| 601 return isolate->builtins()->StoreIC_Initialize_Strict(); |
| 602 } else { |
| 603 return isolate->builtins()->StoreIC_Initialize(); |
| 604 } |
| 635 } | 605 } |
| 636 static Handle<Code> initialize_stub_strict(Isolate* isolate) { | 606 |
| 637 return isolate->builtins()->StoreIC_Initialize_Strict(); | |
| 638 } | |
| 639 static void Clear(Isolate* isolate, Address address, Code* target); | 607 static void Clear(Isolate* isolate, Address address, Code* target); |
| 640 | 608 |
| 609 StrictModeFlag strict_mode_; |
| 610 |
| 641 friend class IC; | 611 friend class IC; |
| 642 }; | 612 }; |
| 643 | 613 |
| 644 | 614 |
| 645 enum KeyedStoreCheckMap { | 615 enum KeyedStoreCheckMap { |
| 646 kDontCheckMap, | 616 kDontCheckMap, |
| 647 kCheckMap | 617 kCheckMap |
| 648 }; | 618 }; |
| 649 | 619 |
| 650 | 620 |
| 651 enum KeyedStoreIncrementLength { | 621 enum KeyedStoreIncrementLength { |
| 652 kDontIncrementLength, | 622 kDontIncrementLength, |
| 653 kIncrementLength | 623 kIncrementLength |
| 654 }; | 624 }; |
| 655 | 625 |
| 656 | 626 |
| 657 class KeyedStoreIC: public StoreIC { | 627 class KeyedStoreIC: public StoreIC { |
| 658 public: | 628 public: |
| 659 KeyedStoreIC(FrameDepth depth, Isolate* isolate) | 629 KeyedStoreIC(FrameDepth depth, Isolate* isolate) |
| 660 : StoreIC(depth, isolate) { | 630 : StoreIC(depth, isolate) { |
| 661 ASSERT(target()->is_keyed_store_stub()); | 631 ASSERT(target()->is_keyed_store_stub()); |
| 662 } | 632 } |
| 663 | 633 |
| 664 MUST_USE_RESULT MaybeObject* Store(State state, | 634 MUST_USE_RESULT MaybeObject* Store(Handle<Object> object, |
| 665 StrictModeFlag strict_mode, | |
| 666 Handle<Object> object, | |
| 667 Handle<Object> name, | 635 Handle<Object> name, |
| 668 Handle<Object> value, | 636 Handle<Object> value, |
| 669 ICMissMode force_generic); | 637 ICMissMode force_generic); |
| 670 | 638 |
| 671 // Code generators for stub routines. Only called once at startup. | 639 // Code generators for stub routines. Only called once at startup. |
| 672 static void GenerateInitialize(MacroAssembler* masm) { | 640 static void GenerateInitialize(MacroAssembler* masm) { |
| 673 GenerateMiss(masm, MISS); | 641 GenerateMiss(masm, MISS); |
| 674 } | 642 } |
| 675 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 643 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 676 GenerateMiss(masm, MISS); | 644 GenerateMiss(masm, MISS); |
| 677 } | 645 } |
| 678 static void GenerateMiss(MacroAssembler* masm, ICMissMode force_generic); | 646 static void GenerateMiss(MacroAssembler* masm, ICMissMode force_generic); |
| 679 static void GenerateSlow(MacroAssembler* masm); | 647 static void GenerateSlow(MacroAssembler* masm); |
| 680 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | 648 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 681 StrictModeFlag strict_mode); | 649 StrictModeFlag strict_mode); |
| 682 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); | 650 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); |
| 683 static void GenerateNonStrictArguments(MacroAssembler* masm); | 651 static void GenerateNonStrictArguments(MacroAssembler* masm); |
| 684 | 652 |
| 685 protected: | 653 protected: |
| 686 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } | 654 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } |
| 687 | 655 |
| 688 virtual Handle<Code> ComputeStoreMonomorphic(LookupResult* lookup, | 656 virtual Handle<Code> ComputeStoreHandler(LookupResult* lookup, |
| 689 StrictModeFlag strict_mode, | 657 Handle<JSObject> receiver, |
| 690 Handle<JSObject> receiver, | 658 Handle<String> name, |
| 691 Handle<String> name, | 659 Handle<Object> value); |
| 692 Handle<Object> value); | |
| 693 virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code) { } | 660 virtual void UpdateMegamorphicCache(Map* map, Name* name, Code* code) { } |
| 694 | 661 |
| 695 virtual Handle<Code> pre_monomorphic_stub() { | 662 virtual Handle<Code> pre_monomorphic_stub() { |
| 696 return pre_monomorphic_stub(isolate()); | 663 return pre_monomorphic_stub(isolate(), strict_mode()); |
| 697 } | 664 } |
| 698 static Handle<Code> pre_monomorphic_stub(Isolate* isolate) { | 665 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
| 699 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); | 666 StrictModeFlag strict_mode) { |
| 700 } | 667 if (strict_mode == kStrictMode) { |
| 701 virtual Handle<Code> pre_monomorphic_stub_strict() { | 668 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); |
| 702 return pre_monomorphic_stub_strict(isolate()); | 669 } else { |
| 703 } | 670 return isolate->builtins()->KeyedStoreIC_PreMonomorphic(); |
| 704 static Handle<Code> pre_monomorphic_stub_strict(Isolate* isolate) { | 671 } |
| 705 return isolate->builtins()->KeyedStoreIC_PreMonomorphic_Strict(); | |
| 706 } | 672 } |
| 707 virtual Handle<Code> megamorphic_stub() { | 673 virtual Handle<Code> megamorphic_stub() { |
| 708 return isolate()->builtins()->KeyedStoreIC_Generic(); | 674 if (strict_mode() == kStrictMode) { |
| 709 } | 675 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
| 710 virtual Handle<Code> megamorphic_stub_strict() { | 676 } else { |
| 711 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | 677 return isolate()->builtins()->KeyedStoreIC_Generic(); |
| 678 } |
| 712 } | 679 } |
| 713 | 680 |
| 714 Handle<Code> StoreElementStub(Handle<JSObject> receiver, | 681 Handle<Code> StoreElementStub(Handle<JSObject> receiver, |
| 715 KeyedAccessStoreMode store_mode, | 682 KeyedAccessStoreMode store_mode); |
| 716 StrictModeFlag strict_mode); | |
| 717 | |
| 718 virtual void UpdateMonomorphicIC(Handle<HeapObject> receiver, | |
| 719 Handle<Code> handler, | |
| 720 Handle<String> name, | |
| 721 StrictModeFlag strict_mode); | |
| 722 | 683 |
| 723 private: | 684 private: |
| 724 void set_target(Code* code) { | 685 void set_target(Code* code) { |
| 725 // Strict mode must be preserved across IC patching. | 686 // Strict mode must be preserved across IC patching. |
| 726 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == | 687 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == strict_mode()); |
| 727 Code::GetStrictMode(target()->extra_ic_state())); | |
| 728 IC::set_target(code); | 688 IC::set_target(code); |
| 729 } | 689 } |
| 730 | 690 |
| 731 // Stub accessors. | 691 // Stub accessors. |
| 732 static Handle<Code> initialize_stub(Isolate* isolate) { | 692 static Handle<Code> initialize_stub(Isolate* isolate, |
| 733 return isolate->builtins()->KeyedStoreIC_Initialize(); | 693 StrictModeFlag strict_mode) { |
| 694 if (strict_mode == kStrictMode) { |
| 695 return isolate->builtins()->KeyedStoreIC_Initialize_Strict(); |
| 696 } else { |
| 697 return isolate->builtins()->KeyedStoreIC_Initialize(); |
| 698 } |
| 734 } | 699 } |
| 735 static Handle<Code> initialize_stub_strict(Isolate* isolate) { | 700 |
| 736 return isolate->builtins()->KeyedStoreIC_Initialize_Strict(); | 701 virtual Handle<Code> generic_stub() const { |
| 702 if (strict_mode() == kStrictMode) { |
| 703 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
| 704 } else { |
| 705 return isolate()->builtins()->KeyedStoreIC_Generic(); |
| 706 } |
| 737 } | 707 } |
| 738 Handle<Code> generic_stub() const { | 708 |
| 739 return isolate()->builtins()->KeyedStoreIC_Generic(); | |
| 740 } | |
| 741 Handle<Code> generic_stub_strict() const { | |
| 742 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | |
| 743 } | |
| 744 Handle<Code> non_strict_arguments_stub() { | 709 Handle<Code> non_strict_arguments_stub() { |
| 745 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); | 710 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); |
| 746 } | 711 } |
| 747 | 712 |
| 748 static void Clear(Isolate* isolate, Address address, Code* target); | 713 static void Clear(Isolate* isolate, Address address, Code* target); |
| 749 | 714 |
| 750 KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver, | 715 KeyedAccessStoreMode GetStoreMode(Handle<JSObject> receiver, |
| 751 Handle<Object> key, | 716 Handle<Object> key, |
| 752 Handle<Object> value); | 717 Handle<Object> value); |
| 753 | 718 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 764 enum TypeInfo { | 729 enum TypeInfo { |
| 765 UNINITIALIZED, | 730 UNINITIALIZED, |
| 766 SMI, | 731 SMI, |
| 767 INT32, | 732 INT32, |
| 768 NUMBER, | 733 NUMBER, |
| 769 ODDBALL, | 734 ODDBALL, |
| 770 STRING, // Only used for addition operation. | 735 STRING, // Only used for addition operation. |
| 771 GENERIC | 736 GENERIC |
| 772 }; | 737 }; |
| 773 | 738 |
| 774 static void StubInfoToType(int minor_key, | 739 explicit BinaryOpIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) { } |
| 775 Handle<Type>* left, | |
| 776 Handle<Type>* right, | |
| 777 Handle<Type>* result, | |
| 778 Isolate* isolate); | |
| 779 | 740 |
| 780 explicit BinaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } | 741 static Builtins::JavaScript TokenToJSBuiltin(Token::Value op); |
| 781 | |
| 782 void patch(Code* code); | |
| 783 | 742 |
| 784 static const char* GetName(TypeInfo type_info); | 743 static const char* GetName(TypeInfo type_info); |
| 785 | 744 |
| 786 static State ToState(TypeInfo type_info); | 745 MUST_USE_RESULT MaybeObject* Transition(Handle<Object> left, |
| 787 | 746 Handle<Object> right); |
| 788 private: | |
| 789 static Handle<Type> TypeInfoToType(TypeInfo binary_type, Isolate* isolate); | |
| 790 }; | 747 }; |
| 791 | 748 |
| 792 | 749 |
| 793 class CompareIC: public IC { | 750 class CompareIC: public IC { |
| 794 public: | 751 public: |
| 795 // The type/state lattice is defined by the following inequations: | 752 // The type/state lattice is defined by the following inequations: |
| 796 // UNINITIALIZED < ... | 753 // UNINITIALIZED < ... |
| 797 // ... < GENERIC | 754 // ... < GENERIC |
| 798 // SMI < NUMBER | 755 // SMI < NUMBER |
| 799 // INTERNALIZED_STRING < STRING | 756 // INTERNALIZED_STRING < STRING |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 | 843 |
| 887 // Helper for BinaryOpIC and CompareIC. | 844 // Helper for BinaryOpIC and CompareIC. |
| 888 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; | 845 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; |
| 889 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); | 846 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); |
| 890 | 847 |
| 891 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure); | 848 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure); |
| 892 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure); | 849 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure); |
| 893 DECLARE_RUNTIME_FUNCTION(MaybeObject*, UnaryOpIC_Miss); | 850 DECLARE_RUNTIME_FUNCTION(MaybeObject*, UnaryOpIC_Miss); |
| 894 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreIC_MissFromStubFailure); | 851 DECLARE_RUNTIME_FUNCTION(MaybeObject*, StoreIC_MissFromStubFailure); |
| 895 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); | 852 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); |
| 853 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); |
| 896 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); | 854 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); |
| 897 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); | 855 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); |
| 898 | 856 |
| 899 | 857 |
| 900 } } // namespace v8::internal | 858 } } // namespace v8::internal |
| 901 | 859 |
| 902 #endif // V8_IC_H_ | 860 #endif // V8_IC_H_ |
| OLD | NEW |