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

Side by Side Diff: src/x64/assembler-x64.cc

Issue 4469002: Improve positions recording for calls. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // ----------------------------------------------------------------------------- 289 // -----------------------------------------------------------------------------
290 // Implementation of Assembler. 290 // Implementation of Assembler.
291 291
292 #ifdef GENERATED_CODE_COVERAGE 292 #ifdef GENERATED_CODE_COVERAGE
293 static void InitCoverageLog(); 293 static void InitCoverageLog();
294 #endif 294 #endif
295 295
296 byte* Assembler::spare_buffer_ = NULL; 296 byte* Assembler::spare_buffer_ = NULL;
297 297
298 Assembler::Assembler(void* buffer, int buffer_size) 298 Assembler::Assembler(void* buffer, int buffer_size)
299 : code_targets_(100) { 299 : code_targets_(100), positions_recorder_(this) {
300 if (buffer == NULL) { 300 if (buffer == NULL) {
301 // Do our own buffer management. 301 // Do our own buffer management.
302 if (buffer_size <= kMinimalBufferSize) { 302 if (buffer_size <= kMinimalBufferSize) {
303 buffer_size = kMinimalBufferSize; 303 buffer_size = kMinimalBufferSize;
304 304
305 if (spare_buffer_ != NULL) { 305 if (spare_buffer_ != NULL) {
306 buffer = spare_buffer_; 306 buffer = spare_buffer_;
307 spare_buffer_ = NULL; 307 spare_buffer_ = NULL;
308 } 308 }
309 } 309 }
(...skipping 20 matching lines...) Expand all
330 memset(buffer_, 0xCC, buffer_size); // int3 330 memset(buffer_, 0xCC, buffer_size); // int3
331 } 331 }
332 #endif 332 #endif
333 333
334 // Setup buffer pointers. 334 // Setup buffer pointers.
335 ASSERT(buffer_ != NULL); 335 ASSERT(buffer_ != NULL);
336 pc_ = buffer_; 336 pc_ = buffer_;
337 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); 337 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_);
338 338
339 last_pc_ = NULL; 339 last_pc_ = NULL;
340 current_statement_position_ = RelocInfo::kNoPosition; 340
341 current_position_ = RelocInfo::kNoPosition;
342 written_statement_position_ = current_statement_position_;
343 written_position_ = current_position_;
344 #ifdef GENERATED_CODE_COVERAGE 341 #ifdef GENERATED_CODE_COVERAGE
345 InitCoverageLog(); 342 InitCoverageLog();
346 #endif 343 #endif
347 } 344 }
348 345
349 346
350 Assembler::~Assembler() { 347 Assembler::~Assembler() {
351 if (own_buffer_) { 348 if (own_buffer_) {
352 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { 349 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) {
353 spare_buffer_ = buffer_; 350 spare_buffer_ = buffer_;
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 } else { 835 } else {
839 ASSERT(L->is_unused()); 836 ASSERT(L->is_unused());
840 int32_t current = pc_offset(); 837 int32_t current = pc_offset();
841 emitl(current); 838 emitl(current);
842 L->link_to(current); 839 L->link_to(current);
843 } 840 }
844 } 841 }
845 842
846 843
847 void Assembler::call(Handle<Code> target, RelocInfo::Mode rmode) { 844 void Assembler::call(Handle<Code> target, RelocInfo::Mode rmode) {
848 WriteRecordedPositions(); 845 positions_recorder()->WriteRecordedPositions();
849 EnsureSpace ensure_space(this); 846 EnsureSpace ensure_space(this);
850 last_pc_ = pc_; 847 last_pc_ = pc_;
851 // 1110 1000 #32-bit disp. 848 // 1110 1000 #32-bit disp.
852 emit(0xE8); 849 emit(0xE8);
853 emit_code_target(target, rmode); 850 emit_code_target(target, rmode);
854 } 851 }
855 852
856 853
857 void Assembler::call(Register adr) { 854 void Assembler::call(Register adr) {
858 EnsureSpace ensure_space(this); 855 EnsureSpace ensure_space(this);
(...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 if (rmode == RelocInfo::EXTERNAL_REFERENCE && 2925 if (rmode == RelocInfo::EXTERNAL_REFERENCE &&
2929 !Serializer::enabled() && 2926 !Serializer::enabled() &&
2930 !FLAG_debug_code) { 2927 !FLAG_debug_code) {
2931 return; 2928 return;
2932 } 2929 }
2933 RelocInfo rinfo(pc_, rmode, data); 2930 RelocInfo rinfo(pc_, rmode, data);
2934 reloc_info_writer.Write(&rinfo); 2931 reloc_info_writer.Write(&rinfo);
2935 } 2932 }
2936 2933
2937 void Assembler::RecordJSReturn() { 2934 void Assembler::RecordJSReturn() {
2938 WriteRecordedPositions(); 2935 positions_recorder()->WriteRecordedPositions();
2939 EnsureSpace ensure_space(this); 2936 EnsureSpace ensure_space(this);
2940 RecordRelocInfo(RelocInfo::JS_RETURN); 2937 RecordRelocInfo(RelocInfo::JS_RETURN);
2941 } 2938 }
2942 2939
2943 2940
2944 void Assembler::RecordDebugBreakSlot() { 2941 void Assembler::RecordDebugBreakSlot() {
2945 WriteRecordedPositions(); 2942 positions_recorder()->WriteRecordedPositions();
2946 EnsureSpace ensure_space(this); 2943 EnsureSpace ensure_space(this);
2947 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT); 2944 RecordRelocInfo(RelocInfo::DEBUG_BREAK_SLOT);
2948 } 2945 }
2949 2946
2950 2947
2951 void Assembler::RecordComment(const char* msg) { 2948 void Assembler::RecordComment(const char* msg) {
2952 if (FLAG_debug_code) { 2949 if (FLAG_debug_code) {
2953 EnsureSpace ensure_space(this); 2950 EnsureSpace ensure_space(this);
2954 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); 2951 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg));
2955 } 2952 }
2956 } 2953 }
2957 2954
2958 2955
2959 void Assembler::RecordPosition(int pos) {
2960 ASSERT(pos != RelocInfo::kNoPosition);
2961 ASSERT(pos >= 0);
2962 current_position_ = pos;
2963 }
2964
2965
2966 void Assembler::RecordStatementPosition(int pos) {
2967 ASSERT(pos != RelocInfo::kNoPosition);
2968 ASSERT(pos >= 0);
2969 current_statement_position_ = pos;
2970 }
2971
2972
2973 bool Assembler::WriteRecordedPositions() {
2974 bool written = false;
2975
2976 // Write the statement position if it is different from what was written last
2977 // time.
2978 if (current_statement_position_ != written_statement_position_) {
2979 EnsureSpace ensure_space(this);
2980 RecordRelocInfo(RelocInfo::STATEMENT_POSITION, current_statement_position_);
2981 written_statement_position_ = current_statement_position_;
2982 written = true;
2983 }
2984
2985 // Write the position if it is different from what was written last time and
2986 // also different from the written statement position.
2987 if (current_position_ != written_position_ &&
2988 current_position_ != written_statement_position_) {
2989 EnsureSpace ensure_space(this);
2990 RecordRelocInfo(RelocInfo::POSITION, current_position_);
2991 written_position_ = current_position_;
2992 written = true;
2993 }
2994
2995 // Return whether something was written.
2996 return written;
2997 }
2998
2999
3000 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask | 2956 const int RelocInfo::kApplyMask = RelocInfo::kCodeTargetMask |
3001 1 << RelocInfo::INTERNAL_REFERENCE; 2957 1 << RelocInfo::INTERNAL_REFERENCE;
3002 2958
3003 2959
3004 bool RelocInfo::IsCodedSpecially() { 2960 bool RelocInfo::IsCodedSpecially() {
3005 // The deserializer needs to know whether a pointer is specially coded. Being 2961 // The deserializer needs to know whether a pointer is specially coded. Being
3006 // specially coded on x64 means that it is a relative 32 bit address, as used 2962 // specially coded on x64 means that it is a relative 32 bit address, as used
3007 // by branch instructions. 2963 // by branch instructions.
3008 return (1 << rmode_) & kApplyMask; 2964 return (1 << rmode_) & kApplyMask;
3009 } 2965 }
3010 2966
3011 2967
3012 2968
3013 } } // namespace v8::internal 2969 } } // namespace v8::internal
3014 2970
3015 #endif // V8_TARGET_ARCH_X64 2971 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/assembler.h ('K') | « src/x64/assembler-x64.h ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698