2012-01-25 16:31:25 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2010-02-15 14:24:38 +00:00
|
|
|
|
2010-03-25 12:44:15 +00:00
|
|
|
#ifndef V8_TYPE_INFO_H_
|
|
|
|
#define V8_TYPE_INFO_H_
|
2010-02-15 14:24:38 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/allocation.h"
|
2016-09-02 13:03:56 +00:00
|
|
|
#include "src/ast/ast-types.h"
|
2015-08-20 07:44:00 +00:00
|
|
|
#include "src/contexts.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/globals.h"
|
2015-11-26 16:22:34 +00:00
|
|
|
#include "src/parsing/token.h"
|
2016-09-20 16:07:25 +00:00
|
|
|
#include "src/zone/zone.h"
|
2010-03-24 15:55:15 +00:00
|
|
|
|
2010-02-15 14:24:38 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Forward declarations.
|
2011-08-22 14:23:37 +00:00
|
|
|
class SmallMapList;
|
2016-04-06 12:06:46 +00:00
|
|
|
class FeedbackNexus;
|
2016-07-13 10:24:55 +00:00
|
|
|
class StubCache;
|
2010-03-05 23:54:13 +00:00
|
|
|
|
2012-07-17 16:24:40 +00:00
|
|
|
class TypeFeedbackOracle: public ZoneObject {
|
2010-12-07 11:31:57 +00:00
|
|
|
public:
|
2015-01-23 15:19:34 +00:00
|
|
|
TypeFeedbackOracle(Isolate* isolate, Zone* zone, Handle<Code> code,
|
2014-09-18 09:59:53 +00:00
|
|
|
Handle<TypeFeedbackVector> feedback_vector,
|
2015-01-23 15:19:34 +00:00
|
|
|
Handle<Context> native_context);
|
2010-03-24 12:34:27 +00:00
|
|
|
|
2015-10-01 13:48:05 +00:00
|
|
|
InlineCacheState LoadInlineCacheState(FeedbackVectorSlot slot);
|
|
|
|
bool StoreIsUninitialized(FeedbackVectorSlot slot);
|
|
|
|
bool CallIsUninitialized(FeedbackVectorSlot slot);
|
|
|
|
bool CallIsMonomorphic(FeedbackVectorSlot slot);
|
2014-10-10 13:22:10 +00:00
|
|
|
bool CallNewIsMonomorphic(FeedbackVectorSlot slot);
|
2010-03-24 12:34:27 +00:00
|
|
|
|
2013-05-27 13:59:20 +00:00
|
|
|
// TODO(1571) We can't use ForInStatement::ForInType as the return value due
|
|
|
|
// to various cycles in our headers.
|
2013-11-28 13:16:51 +00:00
|
|
|
// TODO(rossberg): once all oracle access is removed from ast.cc, it should
|
|
|
|
// be possible.
|
2014-10-10 13:22:10 +00:00
|
|
|
byte ForInType(FeedbackVectorSlot feedback_vector_slot);
|
2012-03-02 11:33:33 +00:00
|
|
|
|
2015-10-01 13:48:05 +00:00
|
|
|
void GetStoreModeAndKeyType(FeedbackVectorSlot slot,
|
2015-08-28 09:01:22 +00:00
|
|
|
KeyedAccessStoreMode* store_mode,
|
|
|
|
IcCheckType* key_type);
|
2013-03-06 21:51:07 +00:00
|
|
|
|
2015-10-01 13:48:05 +00:00
|
|
|
void PropertyReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name,
|
2014-11-27 16:36:18 +00:00
|
|
|
SmallMapList* receiver_types);
|
2015-10-01 13:48:05 +00:00
|
|
|
void KeyedPropertyReceiverTypes(FeedbackVectorSlot slot,
|
2014-12-19 13:40:59 +00:00
|
|
|
SmallMapList* receiver_types, bool* is_string,
|
|
|
|
IcCheckType* key_type);
|
2015-10-01 13:48:05 +00:00
|
|
|
void AssignmentReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name,
|
2015-08-28 09:01:22 +00:00
|
|
|
SmallMapList* receiver_types);
|
2015-10-01 13:48:05 +00:00
|
|
|
void KeyedAssignmentReceiverTypes(FeedbackVectorSlot slot,
|
2015-08-28 09:01:22 +00:00
|
|
|
SmallMapList* receiver_types,
|
|
|
|
KeyedAccessStoreMode* store_mode,
|
|
|
|
IcCheckType* key_type);
|
2015-10-01 13:48:05 +00:00
|
|
|
void CountReceiverTypes(FeedbackVectorSlot slot,
|
2015-09-10 15:02:21 +00:00
|
|
|
SmallMapList* receiver_types);
|
2013-11-28 15:25:38 +00:00
|
|
|
|
2015-10-01 13:48:05 +00:00
|
|
|
void CollectReceiverTypes(FeedbackVectorSlot slot, SmallMapList* types);
|
2016-04-06 12:06:46 +00:00
|
|
|
void CollectReceiverTypes(FeedbackNexus* nexus, SmallMapList* types);
|
2013-12-12 14:57:00 +00:00
|
|
|
|
2015-03-26 11:21:52 +00:00
|
|
|
static bool IsRelevantFeedback(Map* map, Context* native_context) {
|
|
|
|
Object* constructor = map->GetConstructor();
|
|
|
|
return !constructor->IsJSFunction() ||
|
|
|
|
JSFunction::cast(constructor)->context()->native_context() ==
|
|
|
|
native_context;
|
|
|
|
}
|
2011-12-14 14:01:54 +00:00
|
|
|
|
2015-10-01 13:48:05 +00:00
|
|
|
Handle<JSFunction> GetCallTarget(FeedbackVectorSlot slot);
|
|
|
|
Handle<AllocationSite> GetCallAllocationSite(FeedbackVectorSlot slot);
|
2014-10-10 13:22:10 +00:00
|
|
|
Handle<JSFunction> GetCallNewTarget(FeedbackVectorSlot slot);
|
|
|
|
Handle<AllocationSite> GetCallNewAllocationSite(FeedbackVectorSlot slot);
|
2011-09-27 11:42:02 +00:00
|
|
|
|
2016-02-29 12:16:00 +00:00
|
|
|
// TODO(1571) We can't use ToBooleanICStub::Types as the return value because
|
2013-05-27 13:59:20 +00:00
|
|
|
// of various cycles in our headers. Death to tons of implementations in
|
2011-07-25 14:08:36 +00:00
|
|
|
// headers!! :-P
|
2015-06-25 04:32:07 +00:00
|
|
|
uint16_t ToBooleanTypes(TypeFeedbackId id);
|
2013-04-24 11:32:17 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
// Get type information for arithmetic operations and compares.
|
2016-09-27 08:03:20 +00:00
|
|
|
void BinaryType(TypeFeedbackId id, FeedbackVectorSlot slot, AstType** left,
|
|
|
|
AstType** right, AstType** result,
|
|
|
|
Maybe<int>* fixed_right_arg,
|
2014-01-02 15:31:27 +00:00
|
|
|
Handle<AllocationSite>* allocation_site,
|
2013-10-04 08:17:11 +00:00
|
|
|
Token::Value operation);
|
2013-06-21 11:10:06 +00:00
|
|
|
|
2016-09-27 08:03:20 +00:00
|
|
|
void CompareType(TypeFeedbackId id, FeedbackVectorSlot slot, AstType** left,
|
|
|
|
AstType** right, AstType** combined);
|
2013-06-12 17:20:37 +00:00
|
|
|
|
2016-09-27 08:03:20 +00:00
|
|
|
AstType* CountType(TypeFeedbackId id, FeedbackVectorSlot slot);
|
2013-06-12 17:20:37 +00:00
|
|
|
|
2012-06-11 12:42:31 +00:00
|
|
|
Zone* zone() const { return zone_; }
|
2015-01-23 15:19:34 +00:00
|
|
|
Isolate* isolate() const { return isolate_; }
|
2012-06-11 12:42:31 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
private:
|
2016-07-13 10:24:55 +00:00
|
|
|
void CollectReceiverTypes(StubCache* stub_cache, FeedbackVectorSlot slot,
|
2016-07-21 12:57:26 +00:00
|
|
|
Handle<Name> name, SmallMapList* types);
|
2016-07-13 10:24:55 +00:00
|
|
|
void CollectReceiverTypes(StubCache* stub_cache, FeedbackNexus* nexus,
|
2016-07-21 12:57:26 +00:00
|
|
|
Handle<Name> name, SmallMapList* types);
|
2014-11-27 16:36:18 +00:00
|
|
|
|
|
|
|
// Returns true if there is at least one string map and if
|
|
|
|
// all maps are string maps.
|
|
|
|
bool HasOnlyStringMaps(SmallMapList* receiver_types);
|
2010-03-05 23:54:13 +00:00
|
|
|
|
2013-12-02 13:49:32 +00:00
|
|
|
void SetInfo(TypeFeedbackId id, Object* target);
|
2011-03-30 15:31:16 +00:00
|
|
|
|
2011-06-20 12:33:08 +00:00
|
|
|
void BuildDictionary(Handle<Code> code);
|
|
|
|
void GetRelocInfos(Handle<Code> code, ZoneList<RelocInfo>* infos);
|
|
|
|
void CreateDictionary(Handle<Code> code, ZoneList<RelocInfo>* infos);
|
|
|
|
void RelocateRelocInfos(ZoneList<RelocInfo>* infos,
|
2014-03-12 17:18:49 +00:00
|
|
|
Code* old_code,
|
|
|
|
Code* new_code);
|
2011-06-20 12:33:08 +00:00
|
|
|
void ProcessRelocInfos(ZoneList<RelocInfo>* infos);
|
2010-03-24 12:34:27 +00:00
|
|
|
|
2011-03-07 16:09:56 +00:00
|
|
|
// Returns an element from the backing store. Returns undefined if
|
|
|
|
// there is no information.
|
2013-12-02 13:49:32 +00:00
|
|
|
Handle<Object> GetInfo(TypeFeedbackId id);
|
2011-03-07 16:09:56 +00:00
|
|
|
|
2014-02-10 21:38:17 +00:00
|
|
|
// Returns an element from the type feedback vector. Returns undefined
|
|
|
|
// if there is no information.
|
2014-10-10 13:22:10 +00:00
|
|
|
Handle<Object> GetInfo(FeedbackVectorSlot slot);
|
2014-02-10 21:38:17 +00:00
|
|
|
|
2013-03-01 16:06:34 +00:00
|
|
|
private:
|
2012-08-17 09:03:08 +00:00
|
|
|
Handle<Context> native_context_;
|
2015-01-23 15:19:34 +00:00
|
|
|
Isolate* isolate_;
|
2012-06-11 12:42:31 +00:00
|
|
|
Zone* zone_;
|
2013-03-12 07:06:36 +00:00
|
|
|
Handle<UnseededNumberDictionary> dictionary_;
|
2014-09-18 09:59:53 +00:00
|
|
|
Handle<TypeFeedbackVector> feedback_vector_;
|
2010-03-24 12:34:27 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle);
|
|
|
|
};
|
2010-03-05 23:54:13 +00:00
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2010-02-15 14:24:38 +00:00
|
|
|
|
2010-03-25 12:44:15 +00:00
|
|
|
#endif // V8_TYPE_INFO_H_
|