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

Side by Side Diff: src/ic.h

Issue 172523002: Create a function call IC (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments. Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
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 24 matching lines...) Expand all
35 35
36 36
37 const int kMaxKeyedPolymorphism = 4; 37 const int kMaxKeyedPolymorphism = 4;
38 38
39 39
40 // IC_UTIL_LIST defines all utility functions called from generated 40 // IC_UTIL_LIST defines all utility functions called from generated
41 // inline caching code. The argument for the macro, ICU, is the function name. 41 // inline caching code. The argument for the macro, ICU, is the function name.
42 #define IC_UTIL_LIST(ICU) \ 42 #define IC_UTIL_LIST(ICU) \
43 ICU(LoadIC_Miss) \ 43 ICU(LoadIC_Miss) \
44 ICU(KeyedLoadIC_Miss) \ 44 ICU(KeyedLoadIC_Miss) \
45 ICU(CallIC_Miss) \
45 ICU(StoreIC_Miss) \ 46 ICU(StoreIC_Miss) \
46 ICU(StoreIC_ArrayLength) \ 47 ICU(StoreIC_ArrayLength) \
47 ICU(StoreIC_Slow) \ 48 ICU(StoreIC_Slow) \
48 ICU(SharedStoreIC_ExtendStorage) \ 49 ICU(SharedStoreIC_ExtendStorage) \
49 ICU(KeyedStoreIC_Miss) \ 50 ICU(KeyedStoreIC_Miss) \
50 ICU(KeyedStoreIC_Slow) \ 51 ICU(KeyedStoreIC_Slow) \
51 /* Utilities for IC stubs. */ \ 52 /* Utilities for IC stubs. */ \
52 ICU(StoreCallbackProperty) \ 53 ICU(StoreCallbackProperty) \
53 ICU(LoadPropertyWithInterceptorOnly) \ 54 ICU(LoadPropertyWithInterceptorOnly) \
54 ICU(LoadPropertyWithInterceptorForLoad) \ 55 ICU(LoadPropertyWithInterceptorForLoad) \
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 ConstantPoolArray* constant_pool); 107 ConstantPoolArray* constant_pool);
107 108
108 #ifdef DEBUG 109 #ifdef DEBUG
109 bool IsLoadStub() const { 110 bool IsLoadStub() const {
110 return target()->is_load_stub() || target()->is_keyed_load_stub(); 111 return target()->is_load_stub() || target()->is_keyed_load_stub();
111 } 112 }
112 113
113 bool IsStoreStub() const { 114 bool IsStoreStub() const {
114 return target()->is_store_stub() || target()->is_keyed_store_stub(); 115 return target()->is_store_stub() || target()->is_keyed_store_stub();
115 } 116 }
117
118 bool IsCallStub() const {
119 return target()->is_call_stub();
120 }
116 #endif 121 #endif
117 122
118 // Determines which map must be used for keeping the code stub. 123 // Determines which map must be used for keeping the code stub.
119 // These methods should not be called with undefined or null. 124 // These methods should not be called with undefined or null.
120 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); 125 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object);
121 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* 126 // TODO(verwaest): This currently returns a HeapObject rather than JSObject*
122 // since loading the IC for loading the length from strings are stored on 127 // since loading the IC for loading the length from strings are stored on
123 // the string map directly, rather than on the JSObject-typed prototype. 128 // the string map directly, rather than on the JSObject-typed prototype.
124 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, 129 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate,
125 Object* object, 130 Object* object,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 299
295 Address address() const { return address_; } 300 Address address() const { return address_; }
296 301
297 IC::UtilityId id() const { return id_; } 302 IC::UtilityId id() const { return id_; }
298 private: 303 private:
299 Address address_; 304 Address address_;
300 IC::UtilityId id_; 305 IC::UtilityId id_;
301 }; 306 };
302 307
303 308
309 class CallIC: public IC {
310 public:
311 enum CallType { METHOD, FUNCTION };
312 enum StubType { DEFAULT, MONOMORPHIC };
313 enum ArgumentCheck { ARGUMENTS_MUST_MATCH, ARGUMENTS_COUNT_UNKNOWN };
314 enum FunctionAttributes { SLOPPY_OR_NONNATIVE, STRICT_OR_NATIVE };
Toon Verwaest 2014/03/27 16:02:25 SLOPPY_NONNATIVE
mvstanton 2014/04/01 13:01:49 Done.
315
316 class State V8_FINAL BASE_EMBEDDED {
317 public:
318 explicit State(ExtraICState extra_ic_state);
319
320 static State MonomorphicCallState(int argc, CallType call_type,
321 ArgumentCheck argument_check,
322 FunctionAttributes attributes) {
323 return State(argc, call_type, MONOMORPHIC, argument_check, attributes);
324 }
325
326 static State SlowCallState(int argc, CallType call_type) {
327 return State(argc, call_type, DEFAULT, ARGUMENTS_COUNT_UNKNOWN,
328 SLOPPY_OR_NONNATIVE);
329 }
330
331 static State DefaultCallState(int argc, CallType call_type) {
332 return State(argc, call_type, DEFAULT, ARGUMENTS_MUST_MATCH,
333 SLOPPY_OR_NONNATIVE);
334 }
335
336 // Transition from the current state to another.
337 State ToGenericState();
338 State ToMonomorphicState(Handle<JSFunction> function);
339
340 InlineCacheState GetICState() const {
341 return stub_type_ == CallIC::MONOMORPHIC
342 ? ::v8::internal::MONOMORPHIC
343 : ::v8::internal::GENERIC;
344 }
345
346 ExtraICState GetExtraICState() const;
347
348 static void GenerateAheadOfTime(
349 Isolate*, void (*Generate)(Isolate*, const State&));
350
351 int arg_count() const { return argc_; }
352 CallType call_type() const { return call_type_; }
353 StubType stub_type() const { return stub_type_; }
354 ArgumentCheck argument_check() const { return argument_check_; }
355 FunctionAttributes function_attributes() const {
356 return function_attributes_;
357 }
358
359 bool ArgumentsMustMatch() const {
360 return argument_check_ == ARGUMENTS_MUST_MATCH;
361 }
362 bool IsGeneric() const { return stub_type_ == DEFAULT; }
363 bool CallAsMethod() const { return call_type_ == METHOD; }
364 bool IsSloppyOrNonNative() const {
365 return function_attributes_ == SLOPPY_OR_NONNATIVE;
366 }
367
368 void Print(StringStream* stream) const;
369
370 bool operator==(const State& other_state) const {
371 return (argc_ == other_state.argc_ &&
372 call_type_ == other_state.call_type_ &&
373 stub_type_ == other_state.stub_type_ &&
374 argument_check_ == other_state.argument_check_ &&
375 function_attributes_ == other_state.function_attributes_);
376 }
377
378 bool operator!=(const State& other_state) const {
379 return !(*this == other_state);
380 }
381
382 private:
383 State(int argc,
384 CallType call_type,
385 StubType stub_type,
386 ArgumentCheck argument_check,
387 FunctionAttributes attributes)
388 : argc_(argc),
389 call_type_(call_type),
390 stub_type_(stub_type),
391 argument_check_(argument_check),
392 function_attributes_(attributes) {
393 }
394
395 class ArgBits: public BitField<int, 0, Code::kArgumentsBits> {};
Toon Verwaest 2014/03/27 16:02:25 Arg or ArgcBits? Just make sure it's consistent ev
mvstanton 2014/04/01 13:01:49 Done, I went with ArgcBits.
396 class CallTypeBits: public BitField<CallType, Code::kArgumentsBits, 1> {};
397 class StubTypeBits:
398 public BitField<StubType, Code::kArgumentsBits + 1, 1> {}; // NOLINT
399 class ArgumentCheckBits:
400 public BitField<ArgumentCheck,
401 Code::kArgumentsBits + 2, 1> {}; // NOLINT
402 class FunctionAttributeBits:
403 public BitField<FunctionAttributes,
404 Code::kArgumentsBits + 3, 1> {}; // NOLINT
405
406 const int argc_;
407 const CallType call_type_;
408 const StubType stub_type_;
409 const ArgumentCheck argument_check_;
410 const FunctionAttributes function_attributes_;
411 };
412
413 explicit CallIC(Isolate* isolate)
414 : IC(EXTRA_CALL_FRAME, isolate) {
415 }
416
417 void HandleMiss(Handle<Object> receiver,
418 Handle<Object> function,
419 Handle<FixedArray> vector,
420 Handle<Smi> slot);
421
422 // Code generator routines.
423 static Handle<Code> initialize_stub(Isolate* isolate,
424 int argc,
425 CallType call_type);
426
427 static void Clear(Isolate* isolate, Address address, Code* target,
428 ConstantPoolArray* constant_pool);
429 };
430
431
304 class LoadIC: public IC { 432 class LoadIC: public IC {
305 public: 433 public:
306 // ExtraICState bits 434 // ExtraICState bits
307 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {}; 435 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {};
308 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); 436 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0);
309 437
310 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { 438 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) {
311 return ContextualModeBits::encode(contextual_mode); 439 return ContextualModeBits::encode(contextual_mode);
312 } 440 }
313 441
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); 1055 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss);
928 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); 1056 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss);
929 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); 1057 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite);
930 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); 1058 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss);
931 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); 1059 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss);
932 1060
933 1061
934 } } // namespace v8::internal 1062 } } // namespace v8::internal
935 1063
936 #endif // V8_IC_H_ 1064 #endif // V8_IC_H_
OLDNEW
« src/ia32/debug-ia32.cc ('K') | « src/ia32/lithium-codegen-ia32.cc ('k') | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698