2012-01-25 16:31:25 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2010-02-15 14:24:38 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
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
|
|
|
|
2011-05-06 06:50:20 +00:00
|
|
|
#include "allocation.h"
|
2010-03-24 15:55:15 +00:00
|
|
|
#include "globals.h"
|
2013-06-12 17:20:37 +00:00
|
|
|
#include "types.h"
|
2010-12-07 11:31:57 +00:00
|
|
|
#include "zone-inl.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.
|
2013-01-21 14:53:29 +00:00
|
|
|
class ICStub;
|
2011-08-22 14:23:37 +00:00
|
|
|
class SmallMapList;
|
|
|
|
|
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:
|
2011-10-10 09:21:48 +00:00
|
|
|
TypeFeedbackOracle(Handle<Code> code,
|
2012-08-17 09:03:08 +00:00
|
|
|
Handle<Context> native_context,
|
2012-06-11 12:42:31 +00:00
|
|
|
Zone* zone);
|
2010-03-24 12:34:27 +00:00
|
|
|
|
2013-11-28 15:25:38 +00:00
|
|
|
bool LoadIsUninitialized(TypeFeedbackId id);
|
2013-12-02 13:49:32 +00:00
|
|
|
bool StoreIsUninitialized(TypeFeedbackId id);
|
|
|
|
bool StoreIsKeyedPolymorphic(TypeFeedbackId id);
|
2014-02-10 21:38:17 +00:00
|
|
|
bool CallIsMonomorphic(int slot);
|
2013-12-02 13:49:32 +00:00
|
|
|
bool CallIsMonomorphic(TypeFeedbackId aid);
|
2014-02-10 21:38:17 +00:00
|
|
|
bool KeyedArrayCallIsHoley(TypeFeedbackId id);
|
|
|
|
bool CallNewIsMonomorphic(int 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-02-10 21:38:17 +00:00
|
|
|
byte ForInType(int feedback_vector_slot);
|
2012-03-02 11:33:33 +00:00
|
|
|
|
2013-12-02 13:49:32 +00:00
|
|
|
KeyedAccessStoreMode GetStoreMode(TypeFeedbackId id);
|
2013-03-06 21:51:07 +00:00
|
|
|
|
2013-11-28 15:25:38 +00:00
|
|
|
void PropertyReceiverTypes(TypeFeedbackId id,
|
|
|
|
Handle<String> name,
|
|
|
|
SmallMapList* receiver_types,
|
|
|
|
bool* is_prototype);
|
|
|
|
void KeyedPropertyReceiverTypes(TypeFeedbackId id,
|
|
|
|
SmallMapList* receiver_types,
|
|
|
|
bool* is_string);
|
2013-12-02 13:49:32 +00:00
|
|
|
void AssignmentReceiverTypes(TypeFeedbackId id,
|
|
|
|
Handle<String> name,
|
|
|
|
SmallMapList* receiver_types);
|
|
|
|
void KeyedAssignmentReceiverTypes(TypeFeedbackId id,
|
|
|
|
SmallMapList* receiver_types,
|
|
|
|
KeyedAccessStoreMode* store_mode);
|
2013-11-28 15:25:38 +00:00
|
|
|
void CountReceiverTypes(TypeFeedbackId id,
|
|
|
|
SmallMapList* receiver_types);
|
|
|
|
|
2013-12-12 14:57:00 +00:00
|
|
|
void CollectReceiverTypes(TypeFeedbackId id,
|
|
|
|
SmallMapList* types);
|
|
|
|
|
2012-08-17 09:03:08 +00:00
|
|
|
static bool CanRetainOtherContext(Map* map, Context* native_context);
|
2011-12-14 14:01:54 +00:00
|
|
|
static bool CanRetainOtherContext(JSFunction* function,
|
2012-08-17 09:03:08 +00:00
|
|
|
Context* native_context);
|
2011-12-14 14:01:54 +00:00
|
|
|
|
2014-02-10 21:38:17 +00:00
|
|
|
Handle<JSFunction> GetCallTarget(int slot);
|
|
|
|
Handle<JSFunction> GetCallNewTarget(int slot);
|
|
|
|
Handle<AllocationSite> GetCallNewAllocationSite(int slot);
|
2011-09-27 11:42:02 +00:00
|
|
|
|
2013-11-28 15:25:38 +00:00
|
|
|
bool LoadIsBuiltin(TypeFeedbackId id, Builtins::Name builtin_id);
|
|
|
|
bool LoadIsStub(TypeFeedbackId id, ICStub* stub);
|
2010-03-05 23:54:13 +00:00
|
|
|
|
2011-07-25 14:08:36 +00:00
|
|
|
// TODO(1571) We can't use ToBooleanStub::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
|
2013-06-12 17:20:37 +00:00
|
|
|
byte 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.
|
2013-06-14 17:02:39 +00:00
|
|
|
void BinaryType(TypeFeedbackId id,
|
2014-01-21 16:22:52 +00:00
|
|
|
Type** left,
|
|
|
|
Type** right,
|
|
|
|
Type** result,
|
2013-12-04 09:27:48 +00:00
|
|
|
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
|
|
|
|
|
|
|
void CompareType(TypeFeedbackId id,
|
2014-01-21 16:22:52 +00:00
|
|
|
Type** left,
|
|
|
|
Type** right,
|
|
|
|
Type** combined);
|
2013-06-12 17:20:37 +00:00
|
|
|
|
2014-01-21 16:22:52 +00:00
|
|
|
Type* CountType(TypeFeedbackId id);
|
2013-06-12 17:20:37 +00:00
|
|
|
|
2012-06-11 12:42:31 +00:00
|
|
|
Zone* zone() const { return zone_; }
|
2014-01-21 16:22:52 +00:00
|
|
|
Isolate* isolate() const { return zone_->isolate(); }
|
2012-06-11 12:42:31 +00:00
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
private:
|
2013-12-02 13:49:32 +00:00
|
|
|
void CollectReceiverTypes(TypeFeedbackId id,
|
2011-08-22 14:23:37 +00:00
|
|
|
Handle<String> name,
|
|
|
|
Code::Flags flags,
|
|
|
|
SmallMapList* 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.
|
|
|
|
Handle<Object> GetInfo(int slot);
|
|
|
|
|
2013-03-01 16:06:34 +00:00
|
|
|
private:
|
2012-08-17 09:03:08 +00:00
|
|
|
Handle<Context> native_context_;
|
2012-06-11 12:42:31 +00:00
|
|
|
Zone* zone_;
|
2013-03-12 07:06:36 +00:00
|
|
|
Handle<UnseededNumberDictionary> dictionary_;
|
2014-02-10 21:38:17 +00:00
|
|
|
Handle<FixedArray> 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
|
|
|
|
2010-02-15 14:24:38 +00:00
|
|
|
} } // namespace v8::internal
|
|
|
|
|
2010-03-25 12:44:15 +00:00
|
|
|
#endif // V8_TYPE_INFO_H_
|