1
// Copyright 2011 the V8 project authors. All rights reserved.
1
// Copyright 2012 the V8 project authors. All rights reserved.
2
2
// Redistribution and use in source and binary forms, with or without
3
3
// modification, are permitted provided that the following conditions are
64
65
static TypeInfo Integer32() { return TypeInfo(kInteger32); }
65
66
// We know it's a Smi.
66
67
static TypeInfo Smi() { return TypeInfo(kSmi); }
68
// We know it's a Symbol.
69
static TypeInfo Symbol() { return TypeInfo(kSymbol); }
67
70
// We know it's a heap number.
68
71
static TypeInfo Double() { return TypeInfo(kDouble); }
69
72
// We know it's a string.
137
140
return ((type_ & kSmi) == kSmi);
143
inline bool IsSymbol() {
144
ASSERT(type_ != kUninitialized);
145
return ((type_ & kSymbol) == kSymbol);
148
inline bool IsNonSymbol() {
149
ASSERT(type_ != kUninitialized);
150
return ((type_ & kSymbol) == kString);
140
153
inline bool IsInteger32() {
141
154
ASSERT(type_ != kUninitialized);
142
155
return ((type_ & kInteger32) == kInteger32);
168
181
case kNumber: return "Number";
169
182
case kInteger32: return "Integer32";
170
183
case kSmi: return "Smi";
184
case kSymbol: return "Symbol";
171
185
case kDouble: return "Double";
172
186
case kString: return "String";
173
187
case kNonPrimitive: return "Object";
186
200
kSmi = 0x17, // 0010111
187
201
kDouble = 0x19, // 0011001
188
202
kString = 0x30, // 0110000
203
kSymbol = 0x32, // 0110010
189
204
kNonPrimitive = 0x40, // 1000000
190
205
kUninitialized = 0x7f // 1111111
205
220
class Assignment;
206
221
class BinaryOperation;
208
224
class CaseClause;
209
225
class CompareOperation;
210
226
class CompilationInfo;
211
227
class CountOperation;
213
230
class SmallMapList;
214
231
class UnaryOperation;
217
class TypeFeedbackOracle BASE_EMBEDDED {
232
class ForInStatement;
235
class TypeFeedbackOracle: public ZoneObject {
219
TypeFeedbackOracle(Handle<Code> code, Handle<Context> global_context);
237
TypeFeedbackOracle(Handle<Code> code,
238
Handle<Context> native_context,
221
242
bool LoadIsMonomorphicNormal(Property* expr);
243
bool LoadIsUninitialized(Property* expr);
222
244
bool LoadIsMegamorphicWithTypeInfo(Property* expr);
223
bool StoreIsMonomorphicNormal(Expression* expr);
224
bool StoreIsMegamorphicWithTypeInfo(Expression* expr);
245
bool StoreIsMonomorphicNormal(TypeFeedbackId ast_id);
246
bool StoreIsMegamorphicWithTypeInfo(TypeFeedbackId ast_id);
225
247
bool CallIsMonomorphic(Call* expr);
248
bool CallNewIsMonomorphic(CallNew* expr);
249
bool ObjectLiteralStoreIsMonomorphic(ObjectLiteral::Property* prop);
251
bool IsForInFastCase(ForInStatement* expr);
227
253
Handle<Map> LoadMonomorphicReceiverType(Property* expr);
228
Handle<Map> StoreMonomorphicReceiverType(Expression* expr);
254
Handle<Map> StoreMonomorphicReceiverType(TypeFeedbackId ast_id);
230
256
void LoadReceiverTypes(Property* expr,
231
257
Handle<String> name,
237
263
Handle<String> name,
238
264
CallKind call_kind,
239
265
SmallMapList* types);
240
void CollectKeyedReceiverTypes(unsigned ast_id,
266
void CollectKeyedReceiverTypes(TypeFeedbackId ast_id,
241
267
SmallMapList* types);
269
static bool CanRetainOtherContext(Map* map, Context* native_context);
270
static bool CanRetainOtherContext(JSFunction* function,
271
Context* native_context);
243
273
CheckType GetCallCheckType(Call* expr);
244
274
Handle<JSObject> GetPrototypeForPrimitiveCheck(CheckType check);
276
Handle<JSFunction> GetCallTarget(Call* expr);
277
Handle<JSFunction> GetCallNewTarget(CallNew* expr);
279
Handle<Map> GetObjectLiteralStoreMap(ObjectLiteral::Property* prop);
246
281
bool LoadIsBuiltin(Property* expr, Builtins::Name id);
248
283
// TODO(1571) We can't use ToBooleanStub::Types as the return value because
249
284
// of various cylces in our headers. Death to tons of implementations in
251
byte ToBooleanTypes(unsigned ast_id);
286
byte ToBooleanTypes(TypeFeedbackId ast_id);
253
288
// Get type information for arithmetic operations and compares.
254
289
TypeInfo UnaryType(UnaryOperation* expr);
255
290
TypeInfo BinaryType(BinaryOperation* expr);
256
291
TypeInfo CompareType(CompareOperation* expr);
257
292
bool IsSymbolCompare(CompareOperation* expr);
293
Handle<Map> GetCompareMap(CompareOperation* expr);
258
294
TypeInfo SwitchType(CaseClause* clause);
259
295
TypeInfo IncrementType(CountOperation* expr);
297
Zone* zone() const { return zone_; }
262
void CollectReceiverTypes(unsigned ast_id,
300
void CollectReceiverTypes(TypeFeedbackId ast_id,
263
301
Handle<String> name,
264
302
Code::Flags flags,
265
303
SmallMapList* types);
267
void SetInfo(unsigned ast_id, Object* target);
305
void SetInfo(TypeFeedbackId ast_id, Object* target);
269
307
void BuildDictionary(Handle<Code> code);
270
308
void GetRelocInfos(Handle<Code> code, ZoneList<RelocInfo>* infos);
274
312
byte* new_start);
275
313
void ProcessRelocInfos(ZoneList<RelocInfo>* infos);
276
void ProcessTarget(unsigned ast_id, Code* target);
314
void ProcessTypeFeedbackCells(Handle<Code> code);
278
316
// Returns an element from the backing store. Returns undefined if
279
317
// there is no information.
280
Handle<Object> GetInfo(unsigned ast_id);
318
Handle<Object> GetInfo(TypeFeedbackId ast_id);
282
Handle<Context> global_context_;
320
Handle<Context> native_context_;
283
322
Handle<UnseededNumberDictionary> dictionary_;
285
325
DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle);