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

Side by Side Diff: src/ic.h

Issue 224903005: Reland "create a function call IC" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
« no previous file with comments | « src/ia32/lithium-codegen-ia32.cc ('k') | src/ic.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 ConstantPoolArray* constant_pool); 113 ConstantPoolArray* constant_pool);
113 114
114 #ifdef DEBUG 115 #ifdef DEBUG
115 bool IsLoadStub() const { 116 bool IsLoadStub() const {
116 return target()->is_load_stub() || target()->is_keyed_load_stub(); 117 return target()->is_load_stub() || target()->is_keyed_load_stub();
117 } 118 }
118 119
119 bool IsStoreStub() const { 120 bool IsStoreStub() const {
120 return target()->is_store_stub() || target()->is_keyed_store_stub(); 121 return target()->is_store_stub() || target()->is_keyed_store_stub();
121 } 122 }
123
124 bool IsCallStub() const {
125 return target()->is_call_stub();
126 }
122 #endif 127 #endif
123 128
124 // Determines which map must be used for keeping the code stub. 129 // Determines which map must be used for keeping the code stub.
125 // These methods should not be called with undefined or null. 130 // These methods should not be called with undefined or null.
126 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object); 131 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object);
127 // TODO(verwaest): This currently returns a HeapObject rather than JSObject* 132 // TODO(verwaest): This currently returns a HeapObject rather than JSObject*
128 // since loading the IC for loading the length from strings are stored on 133 // since loading the IC for loading the length from strings are stored on
129 // the string map directly, rather than on the JSObject-typed prototype. 134 // the string map directly, rather than on the JSObject-typed prototype.
130 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate, 135 static inline HeapObject* GetCodeCacheHolder(Isolate* isolate,
131 Object* object, 136 Object* object,
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 337
333 Address address() const { return address_; } 338 Address address() const { return address_; }
334 339
335 IC::UtilityId id() const { return id_; } 340 IC::UtilityId id() const { return id_; }
336 private: 341 private:
337 Address address_; 342 Address address_;
338 IC::UtilityId id_; 343 IC::UtilityId id_;
339 }; 344 };
340 345
341 346
347 class CallIC: public IC {
348 public:
349 enum CallType { METHOD, FUNCTION };
350 enum StubType { DEFAULT, MONOMORPHIC };
351 enum ArgumentCheck { ARGUMENTS_MUST_MATCH, ARGUMENTS_COUNT_UNKNOWN };
352
353 class State V8_FINAL BASE_EMBEDDED {
354 public:
355 explicit State(ExtraICState extra_ic_state);
356
357 static State MonomorphicCallState(int argc, CallType call_type,
358 ArgumentCheck argument_check,
359 StrictMode strict_mode) {
360 return State(argc, call_type, MONOMORPHIC, argument_check, strict_mode);
361 }
362
363 static State SlowCallState(int argc, CallType call_type) {
364 return State(argc, call_type, DEFAULT, ARGUMENTS_COUNT_UNKNOWN,
365 SLOPPY);
366 }
367
368 static State DefaultCallState(int argc, CallType call_type) {
369 return State(argc, call_type, DEFAULT, ARGUMENTS_MUST_MATCH,
370 SLOPPY);
371 }
372
373 // Transition from the current state to another.
374 State ToGenericState();
375 State ToMonomorphicState(Handle<JSFunction> function);
376
377 InlineCacheState GetICState() const {
378 return stub_type_ == CallIC::MONOMORPHIC
379 ? ::v8::internal::MONOMORPHIC
380 : ::v8::internal::GENERIC;
381 }
382
383 ExtraICState GetExtraICState() const;
384
385 static void GenerateAheadOfTime(
386 Isolate*, void (*Generate)(Isolate*, const State&));
387
388 int arg_count() const { return argc_; }
389 CallType call_type() const { return call_type_; }
390 StubType stub_type() const { return stub_type_; }
391 ArgumentCheck argument_check() const { return argument_check_; }
392 StrictMode strict_mode() const {
393 return strict_mode_;
394 }
395
396 bool ArgumentsMustMatch() const {
397 return argument_check_ == ARGUMENTS_MUST_MATCH;
398 }
399 bool IsGeneric() const { return stub_type_ == DEFAULT; }
400 bool CallAsMethod() const { return call_type_ == METHOD; }
401 bool IsSloppy() const {
402 return strict_mode_ == SLOPPY;
403 }
404
405 void Print(StringStream* stream) const;
406
407 bool operator==(const State& other_state) const {
408 return (argc_ == other_state.argc_ &&
409 call_type_ == other_state.call_type_ &&
410 stub_type_ == other_state.stub_type_ &&
411 argument_check_ == other_state.argument_check_ &&
412 strict_mode_ == other_state.strict_mode_);
413 }
414
415 bool operator!=(const State& other_state) const {
416 return !(*this == other_state);
417 }
418
419 private:
420 State(int argc,
421 CallType call_type,
422 StubType stub_type,
423 ArgumentCheck argument_check,
424 StrictMode strict_mode)
425 : argc_(argc),
426 call_type_(call_type),
427 stub_type_(stub_type),
428 argument_check_(argument_check),
429 strict_mode_(strict_mode) {
430 }
431
432 class ArgcBits: public BitField<int, 0, Code::kArgumentsBits> {};
433 class CallTypeBits: public BitField<CallType, Code::kArgumentsBits, 1> {};
434 class StubTypeBits:
435 public BitField<StubType, Code::kArgumentsBits + 1, 1> {}; // NOLINT
436 class ArgumentCheckBits:
437 public BitField<ArgumentCheck,
438 Code::kArgumentsBits + 2, 1> {}; // NOLINT
439 class StrictModeBits:
440 public BitField<StrictMode,
441 Code::kArgumentsBits + 3, 1> {}; // NOLINT
442
443 const int argc_;
444 const CallType call_type_;
445 const StubType stub_type_;
446 const ArgumentCheck argument_check_;
447 const StrictMode strict_mode_;
448 };
449
450 explicit CallIC(Isolate* isolate)
451 : IC(EXTRA_CALL_FRAME, isolate) {
452 }
453
454 void HandleMiss(Handle<Object> receiver,
455 Handle<Object> function,
456 Handle<FixedArray> vector,
457 Handle<Smi> slot);
458
459 // Code generator routines.
460 static Handle<Code> initialize_stub(Isolate* isolate,
461 int argc,
462 CallType call_type);
463
464 static void Clear(Isolate* isolate, Address address, Code* target,
465 ConstantPoolArray* constant_pool);
466 };
467
468
342 class LoadIC: public IC { 469 class LoadIC: public IC {
343 public: 470 public:
344 // ExtraICState bits 471 // ExtraICState bits
345 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {}; 472 class ContextualModeBits: public BitField<ContextualMode, 0, 1> {};
346 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0); 473 STATIC_ASSERT(static_cast<int>(NOT_CONTEXTUAL) == 0);
347 474
348 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { 475 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) {
349 return ContextualModeBits::encode(contextual_mode); 476 return ContextualModeBits::encode(contextual_mode);
350 } 477 }
351 478
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss); 1092 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ElementsTransitionAndStoreIC_Miss);
966 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss); 1093 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss);
967 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite); 1094 DECLARE_RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite);
968 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss); 1095 DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss);
969 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss); 1096 DECLARE_RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss);
970 1097
971 1098
972 } } // namespace v8::internal 1099 } } // namespace v8::internal
973 1100
974 #endif // V8_IC_H_ 1101 #endif // V8_IC_H_
OLDNEW
« no previous file with comments | « 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