~ubuntu-branches/ubuntu/saucy/nodejs/saucy-proposed

« back to all changes in this revision

Viewing changes to deps/v8/src/type-info.h

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
4
4
// met:
29
29
#define V8_TYPE_INFO_H_
30
30
 
31
31
#include "allocation.h"
 
32
#include "ast.h"
32
33
#include "globals.h"
33
34
#include "zone-inl.h"
34
35
 
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);
138
141
  }
139
142
 
 
143
  inline bool IsSymbol() {
 
144
    ASSERT(type_ != kUninitialized);
 
145
    return ((type_ & kSymbol) == kSymbol);
 
146
  }
 
147
 
 
148
  inline bool IsNonSymbol() {
 
149
    ASSERT(type_ != kUninitialized);
 
150
    return ((type_ & kSymbol) == kString);
 
151
  }
 
152
 
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
191
206
  };
205
220
class Assignment;
206
221
class BinaryOperation;
207
222
class Call;
 
223
class CallNew;
208
224
class CaseClause;
209
225
class CompareOperation;
210
226
class CompilationInfo;
211
227
class CountOperation;
 
228
class Expression;
212
229
class Property;
213
230
class SmallMapList;
214
231
class UnaryOperation;
215
 
 
216
 
 
217
 
class TypeFeedbackOracle BASE_EMBEDDED {
 
232
class ForInStatement;
 
233
 
 
234
 
 
235
class TypeFeedbackOracle: public ZoneObject {
218
236
 public:
219
 
  TypeFeedbackOracle(Handle<Code> code, Handle<Context> global_context);
 
237
  TypeFeedbackOracle(Handle<Code> code,
 
238
                     Handle<Context> native_context,
 
239
                     Isolate* isolate,
 
240
                     Zone* zone);
220
241
 
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);
 
250
 
 
251
  bool IsForInFastCase(ForInStatement* expr);
226
252
 
227
253
  Handle<Map> LoadMonomorphicReceiverType(Property* expr);
228
 
  Handle<Map> StoreMonomorphicReceiverType(Expression* expr);
 
254
  Handle<Map> StoreMonomorphicReceiverType(TypeFeedbackId ast_id);
229
255
 
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);
242
268
 
 
269
  static bool CanRetainOtherContext(Map* map, Context* native_context);
 
270
  static bool CanRetainOtherContext(JSFunction* function,
 
271
                                    Context* native_context);
 
272
 
243
273
  CheckType GetCallCheckType(Call* expr);
244
274
  Handle<JSObject> GetPrototypeForPrimitiveCheck(CheckType check);
245
275
 
 
276
  Handle<JSFunction> GetCallTarget(Call* expr);
 
277
  Handle<JSFunction> GetCallNewTarget(CallNew* expr);
 
278
 
 
279
  Handle<Map> GetObjectLiteralStoreMap(ObjectLiteral::Property* prop);
 
280
 
246
281
  bool LoadIsBuiltin(Property* expr, Builtins::Name id);
247
282
 
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
250
285
  // headers!! :-P
251
 
  byte ToBooleanTypes(unsigned ast_id);
 
286
  byte ToBooleanTypes(TypeFeedbackId ast_id);
252
287
 
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);
260
296
 
 
297
  Zone* zone() const { return zone_; }
 
298
 
261
299
 private:
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);
266
304
 
267
 
  void SetInfo(unsigned ast_id, Object* target);
 
305
  void SetInfo(TypeFeedbackId ast_id, Object* target);
268
306
 
269
307
  void BuildDictionary(Handle<Code> code);
270
308
  void GetRelocInfos(Handle<Code> code, ZoneList<RelocInfo>* infos);
273
311
                          byte* old_start,
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);
277
315
 
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);
281
319
 
282
 
  Handle<Context> global_context_;
 
320
  Handle<Context> native_context_;
 
321
  Isolate* isolate_;
283
322
  Handle<UnseededNumberDictionary> dictionary_;
 
323
  Zone* zone_;
284
324
 
285
325
  DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle);
286
326
};