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

Side by Side Diff: src/assembler.h

Issue 5699002: RFC: Switch to ast ids (instead of positions) for type feedback. (Closed)
Patch Set: Cleanup Created 10 years 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
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // statement_position). The "position" is collected at places in the source 171 // statement_position). The "position" is collected at places in the source
172 // code which are of interest when making stack traces to pin-point the source 172 // code which are of interest when making stack traces to pin-point the source
173 // location of a stack frame as close as possible. The "statement position" is 173 // location of a stack frame as close as possible. The "statement position" is
174 // collected at the beginning at each statement, and is used to indicate 174 // collected at the beginning at each statement, and is used to indicate
175 // possible break locations. kNoPosition is used to indicate an 175 // possible break locations. kNoPosition is used to indicate an
176 // invalid/uninitialized position value. 176 // invalid/uninitialized position value.
177 static const int kNoPosition = -1; 177 static const int kNoPosition = -1;
178 178
179 enum Mode { 179 enum Mode {
180 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). 180 // Please note the order is important (see IsCodeTarget, IsGCRelocMode).
181 CODE_TARGET, // Code target which is not any of the below.
182 CODE_TARGET_WITH_ID,
181 CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor. 183 CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor.
182 CODE_TARGET_CONTEXT, // Code target used for contextual loads. 184 CODE_TARGET_CONTEXT, // Code target used for contextual loads.
183 DEBUG_BREAK, // Code target for the debugger statement. 185 DEBUG_BREAK, // Code target for the debugger statement.
184 CODE_TARGET, // Code target which is not any of the above.
185 EMBEDDED_OBJECT, 186 EMBEDDED_OBJECT,
186 187
187 GLOBAL_PROPERTY_CELL, 188 GLOBAL_PROPERTY_CELL,
188 189
189 // Everything after runtime_entry (inclusive) is not GC'ed. 190 // Everything after runtime_entry (inclusive) is not GC'ed.
190 RUNTIME_ENTRY, 191 RUNTIME_ENTRY,
191 JS_RETURN, // Marks start of the ExitJSFrame code. 192 JS_RETURN, // Marks start of the ExitJSFrame code.
192 COMMENT, 193 COMMENT,
193 POSITION, // See comment for kNoPosition above. 194 POSITION, // See comment for kNoPosition above.
194 STATEMENT_POSITION, // See comment for kNoPosition above. 195 STATEMENT_POSITION, // See comment for kNoPosition above.
195 DEBUG_BREAK_SLOT, // Additional code inserted for debug break slot. 196 DEBUG_BREAK_SLOT, // Additional code inserted for debug break slot.
196 EXTERNAL_REFERENCE, // The address of an external C++ function. 197 EXTERNAL_REFERENCE, // The address of an external C++ function.
197 INTERNAL_REFERENCE, // An address inside the same function. 198 INTERNAL_REFERENCE, // An address inside the same function.
198 199
199 // add more as needed 200 // add more as needed
200 // Pseudo-types 201 // Pseudo-types
201 NUMBER_OF_MODES, // must be no greater than 14 - see RelocInfoWriter 202 NUMBER_OF_MODES, // must be no greater than ?? - see RelocInfoWriter
fschneider 2011/02/11 11:28:18 Update comment. Maybe a STATIC_ASSERT would be bet
202 NONE, // never recorded 203 NONE, // never recorded
203 LAST_CODE_ENUM = CODE_TARGET, 204 LAST_CODE_ENUM = DEBUG_BREAK,
204 LAST_GCED_ENUM = EMBEDDED_OBJECT 205 LAST_GCED_ENUM = EMBEDDED_OBJECT,
206 // Modes <= LAST_COMPACT_ENUM are guaranteed to have compact
207 // encoding.
208 LAST_COMPACT_ENUM = CODE_TARGET_WITH_ID
205 }; 209 };
206 210
207 211
208 RelocInfo() {} 212 RelocInfo() {}
209 RelocInfo(byte* pc, Mode rmode, intptr_t data) 213 RelocInfo(byte* pc, Mode rmode, intptr_t data)
210 : pc_(pc), rmode_(rmode), data_(data) { 214 : pc_(pc), rmode_(rmode), data_(data) {
211 } 215 }
212 216
213 static inline bool IsConstructCall(Mode mode) { 217 static inline bool IsConstructCall(Mode mode) {
214 return mode == CONSTRUCT_CALL; 218 return mode == CONSTRUCT_CALL;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 static const char* RelocModeName(Mode rmode); 328 static const char* RelocModeName(Mode rmode);
325 void Print(); 329 void Print();
326 #endif // ENABLE_DISASSEMBLER 330 #endif // ENABLE_DISASSEMBLER
327 #ifdef DEBUG 331 #ifdef DEBUG
328 // Debugging 332 // Debugging
329 void Verify(); 333 void Verify();
330 #endif 334 #endif
331 335
332 static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1; 336 static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1;
333 static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION; 337 static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION;
334 static const int kDebugMask = kPositionMask | 1 << COMMENT; 338 static const int kDataMask =
339 (1 << CODE_TARGET_WITH_ID) | kPositionMask | (1 << COMMENT);
335 static const int kApplyMask; // Modes affected by apply. Depends on arch. 340 static const int kApplyMask; // Modes affected by apply. Depends on arch.
336 341
337 private: 342 private:
338 // On ARM, note that pc_ is the address of the constant pool entry 343 // On ARM, note that pc_ is the address of the constant pool entry
339 // to be relocated and not the address of the instruction 344 // to be relocated and not the address of the instruction
340 // referencing the constant pool entry (except when rmode_ == 345 // referencing the constant pool entry (except when rmode_ ==
341 // comment). 346 // comment).
342 byte* pc_; 347 byte* pc_;
343 Mode rmode_; 348 Mode rmode_;
344 intptr_t data_; 349 intptr_t data_;
345 friend class RelocIterator; 350 friend class RelocIterator;
346 }; 351 };
347 352
348 353
349 // RelocInfoWriter serializes a stream of relocation info. It writes towards 354 // RelocInfoWriter serializes a stream of relocation info. It writes towards
350 // lower addresses. 355 // lower addresses.
351 class RelocInfoWriter BASE_EMBEDDED { 356 class RelocInfoWriter BASE_EMBEDDED {
352 public: 357 public:
353 RelocInfoWriter() : pos_(NULL), last_pc_(NULL), last_data_(0) {} 358 RelocInfoWriter() : pos_(NULL),
354 RelocInfoWriter(byte* pos, byte* pc) : pos_(pos), last_pc_(pc), 359 last_pc_(NULL),
355 last_data_(0) {} 360 last_id_(0),
361 last_position_(0) {}
362 RelocInfoWriter(byte* pos, byte* pc) : pos_(pos),
363 last_pc_(pc),
364 last_id_(0),
365 last_position_(0) {}
356 366
357 byte* pos() const { return pos_; } 367 byte* pos() const { return pos_; }
358 byte* last_pc() const { return last_pc_; } 368 byte* last_pc() const { return last_pc_; }
359 369
360 void Write(const RelocInfo* rinfo); 370 void Write(const RelocInfo* rinfo);
361 371
362 // Update the state of the stream after reloc info buffer 372 // Update the state of the stream after reloc info buffer
363 // and/or code is moved while the stream is active. 373 // and/or code is moved while the stream is active.
364 void Reposition(byte* pos, byte* pc) { 374 void Reposition(byte* pos, byte* pc) {
365 pos_ = pos; 375 pos_ = pos;
366 last_pc_ = pc; 376 last_pc_ = pc;
367 } 377 }
368 378
369 // Max size (bytes) of a written RelocInfo. Longest encoding is 379 // Max size (bytes) of a written RelocInfo. Longest encoding is
370 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta. 380 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta.
371 // On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12. 381 // On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12.
372 // On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16; 382 // On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16;
373 // Here we use the maximum of the two. 383 // Here we use the maximum of the two.
374 static const int kMaxSize = 16; 384 static const int kMaxSize = 16;
375 385
376 private: 386 private:
377 inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta); 387 inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta);
378 inline void WriteTaggedPC(uint32_t pc_delta, int tag); 388 inline void WriteTaggedPC(uint32_t pc_delta, int tag);
379 inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag); 389 inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag);
390 inline void WriteExtraTaggedIntData(int data_delta, int top_tag);
380 inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag); 391 inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag);
381 inline void WriteTaggedData(intptr_t data_delta, int tag); 392 inline void WriteTaggedData(intptr_t data_delta, int tag);
382 inline void WriteExtraTag(int extra_tag, int top_tag); 393 inline void WriteExtraTag(int extra_tag, int top_tag);
383 394
384 byte* pos_; 395 byte* pos_;
385 byte* last_pc_; 396 byte* last_pc_;
386 intptr_t last_data_; 397 int last_id_;
398 int last_position_;
387 DISALLOW_COPY_AND_ASSIGN(RelocInfoWriter); 399 DISALLOW_COPY_AND_ASSIGN(RelocInfoWriter);
388 }; 400 };
389 401
390 402
391 // A RelocIterator iterates over relocation information. 403 // A RelocIterator iterates over relocation information.
392 // Typical use: 404 // Typical use:
393 // 405 //
394 // for (RelocIterator it(code); !it.done(); it.next()) { 406 // for (RelocIterator it(code); !it.done(); it.next()) {
395 // // do something with it.rinfo() here 407 // // do something with it.rinfo() here
396 // } 408 // }
(...skipping 21 matching lines...) Expand all
418 private: 430 private:
419 // Advance* moves the position before/after reading. 431 // Advance* moves the position before/after reading.
420 // *Read* reads from current byte(s) into rinfo_. 432 // *Read* reads from current byte(s) into rinfo_.
421 // *Get* just reads and returns info on current byte. 433 // *Get* just reads and returns info on current byte.
422 void Advance(int bytes = 1) { pos_ -= bytes; } 434 void Advance(int bytes = 1) { pos_ -= bytes; }
423 int AdvanceGetTag(); 435 int AdvanceGetTag();
424 int GetExtraTag(); 436 int GetExtraTag();
425 int GetTopTag(); 437 int GetTopTag();
426 void ReadTaggedPC(); 438 void ReadTaggedPC();
427 void AdvanceReadPC(); 439 void AdvanceReadPC();
440 void AdvanceReadId();
441 void AdvanceReadPosition();
428 void AdvanceReadData(); 442 void AdvanceReadData();
429 void AdvanceReadVariableLengthPCJump(); 443 void AdvanceReadVariableLengthPCJump();
430 int GetPositionTypeTag(); 444 int GetLocatableTypeTag();
431 void ReadTaggedData(); 445 void ReadTaggedId();
432 446 void ReadTaggedPosition();
433 static RelocInfo::Mode DebugInfoModeFromTag(int tag);
434 447
435 // If the given mode is wanted, set it in rinfo_ and return true. 448 // If the given mode is wanted, set it in rinfo_ and return true.
436 // Else return false. Used for efficiently skipping unwanted modes. 449 // Else return false. Used for efficiently skipping unwanted modes.
437 bool SetMode(RelocInfo::Mode mode) { 450 bool SetMode(RelocInfo::Mode mode) {
438 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false; 451 return (mode_mask_ & (1 << mode)) ? (rinfo_.rmode_ = mode, true) : false;
439 } 452 }
440 453
441 byte* pos_; 454 byte* pos_;
442 byte* end_; 455 byte* end_;
443 RelocInfo rinfo_; 456 RelocInfo rinfo_;
444 bool done_; 457 bool done_;
445 int mode_mask_; 458 int mode_mask_;
459 int last_id_;
460 int last_position_;
446 DISALLOW_COPY_AND_ASSIGN(RelocIterator); 461 DISALLOW_COPY_AND_ASSIGN(RelocIterator);
447 }; 462 };
448 463
449 464
450 //------------------------------------------------------------------------------ 465 //------------------------------------------------------------------------------
451 // External function 466 // External function
452 467
453 //---------------------------------------------------------------------------- 468 //----------------------------------------------------------------------------
454 class IC_Utility; 469 class IC_Utility;
455 class SCTableReference; 470 class SCTableReference;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 return num_bits_set; 729 return num_bits_set;
715 } 730 }
716 731
717 // Computes pow(x, y) with the special cases in the spec for Math.pow. 732 // Computes pow(x, y) with the special cases in the spec for Math.pow.
718 double power_double_int(double x, int y); 733 double power_double_int(double x, int y);
719 double power_double_double(double x, double y); 734 double power_double_double(double x, double y);
720 735
721 } } // namespace v8::internal 736 } } // namespace v8::internal
722 737
723 #endif // V8_ASSEMBLER_H_ 738 #endif // V8_ASSEMBLER_H_
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.cc ('k') | src/assembler.cc » ('j') | src/assembler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698