OLD | NEW |
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 | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 if (kDebug && own_buffer_) { | 309 if (kDebug && own_buffer_) { |
310 memset(buffer_, 0xCC, buffer_size); // int3 | 310 memset(buffer_, 0xCC, buffer_size); // int3 |
311 } | 311 } |
312 | 312 |
313 // setup buffer pointers | 313 // setup buffer pointers |
314 ASSERT(buffer_ != NULL); | 314 ASSERT(buffer_ != NULL); |
315 pc_ = buffer_; | 315 pc_ = buffer_; |
316 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); | 316 reloc_info_writer.Reposition(buffer_ + buffer_size, pc_); |
317 | 317 |
318 last_pc_ = NULL; | 318 last_pc_ = NULL; |
319 last_position_ = RelocInfo::kNoPosition; | 319 current_statement_position_ = RelocInfo::kNoPosition; |
320 last_statement_position_ = RelocInfo::kNoPosition; | 320 current_position_ = RelocInfo::kNoPosition; |
| 321 written_statement_position_ = current_statement_position_; |
| 322 written_position_ = current_position_; |
321 } | 323 } |
322 | 324 |
323 | 325 |
324 Assembler::~Assembler() { | 326 Assembler::~Assembler() { |
325 if (own_buffer_) { | 327 if (own_buffer_) { |
326 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { | 328 if (spare_buffer_ == NULL && buffer_size_ == kMinimalBufferSize) { |
327 spare_buffer_ = buffer_; | 329 spare_buffer_ = buffer_; |
328 } else { | 330 } else { |
329 DeleteArray(buffer_); | 331 DeleteArray(buffer_); |
330 } | 332 } |
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1957 | 1959 |
1958 void Assembler::RecordComment(const char* msg) { | 1960 void Assembler::RecordComment(const char* msg) { |
1959 if (FLAG_debug_code) { | 1961 if (FLAG_debug_code) { |
1960 EnsureSpace ensure_space(this); | 1962 EnsureSpace ensure_space(this); |
1961 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); | 1963 RecordRelocInfo(RelocInfo::COMMENT, reinterpret_cast<intptr_t>(msg)); |
1962 } | 1964 } |
1963 } | 1965 } |
1964 | 1966 |
1965 | 1967 |
1966 void Assembler::RecordPosition(int pos) { | 1968 void Assembler::RecordPosition(int pos) { |
1967 if (pos == RelocInfo::kNoPosition) return; | 1969 ASSERT(pos != RelocInfo::kNoPosition); |
1968 ASSERT(pos >= 0); | 1970 ASSERT(pos >= 0); |
1969 last_position_ = pos; | 1971 current_position_ = pos; |
1970 } | 1972 } |
1971 | 1973 |
1972 | 1974 |
1973 void Assembler::RecordStatementPosition(int pos) { | 1975 void Assembler::RecordStatementPosition(int pos) { |
1974 if (pos == RelocInfo::kNoPosition) return; | 1976 ASSERT(pos != RelocInfo::kNoPosition); |
1975 ASSERT(pos >= 0); | 1977 ASSERT(pos >= 0); |
1976 last_statement_position_ = pos; | 1978 current_statement_position_ = pos; |
1977 } | 1979 } |
1978 | 1980 |
1979 | 1981 |
1980 void Assembler::WriteRecordedPositions() { | 1982 void Assembler::WriteRecordedPositions() { |
1981 if (last_statement_position_ != RelocInfo::kNoPosition) { | 1983 // Write the statement position if it is different from what was written last |
| 1984 // time. |
| 1985 if (current_statement_position_ != written_statement_position_) { |
1982 EnsureSpace ensure_space(this); | 1986 EnsureSpace ensure_space(this); |
1983 RecordRelocInfo(RelocInfo::STATEMENT_POSITION, last_statement_position_); | 1987 RecordRelocInfo(RelocInfo::STATEMENT_POSITION, current_statement_position_); |
| 1988 written_statement_position_ = current_statement_position_; |
1984 } | 1989 } |
1985 if ((last_position_ != RelocInfo::kNoPosition) && | 1990 |
1986 (last_position_ != last_statement_position_)) { | 1991 // Write the position if it is different from what was written last time and |
| 1992 // also diferent from the written statement position. |
| 1993 if (current_position_ != written_position_ && |
| 1994 current_position_ != written_statement_position_) { |
1987 EnsureSpace ensure_space(this); | 1995 EnsureSpace ensure_space(this); |
1988 RecordRelocInfo(RelocInfo::POSITION, last_position_); | 1996 RecordRelocInfo(RelocInfo::POSITION, current_position_); |
| 1997 written_position_ = current_position_; |
1989 } | 1998 } |
1990 last_statement_position_ = RelocInfo::kNoPosition; | |
1991 last_position_ = RelocInfo::kNoPosition; | |
1992 } | 1999 } |
1993 | 2000 |
1994 | 2001 |
1995 void Assembler::GrowBuffer() { | 2002 void Assembler::GrowBuffer() { |
1996 ASSERT(overflow()); // should not call this otherwise | 2003 ASSERT(overflow()); // should not call this otherwise |
1997 if (!own_buffer_) FATAL("external code buffer is too small"); | 2004 if (!own_buffer_) FATAL("external code buffer is too small"); |
1998 | 2005 |
1999 // compute new buffer size | 2006 // compute new buffer size |
2000 CodeDesc desc; // the new buffer | 2007 CodeDesc desc; // the new buffer |
2001 if (buffer_size_ < 4*KB) { | 2008 if (buffer_size_ < 4*KB) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2132 ASSERT(bound_label.is_bound()); | 2139 ASSERT(bound_label.is_bound()); |
2133 ASSERT(0 <= position); | 2140 ASSERT(0 <= position); |
2134 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); | 2141 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); |
2135 ASSERT(long_at(position) == 0); // only initialize once! | 2142 ASSERT(long_at(position) == 0); // only initialize once! |
2136 | 2143 |
2137 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); | 2144 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); |
2138 long_at_put(position, label_loc); | 2145 long_at_put(position, label_loc); |
2139 } | 2146 } |
2140 | 2147 |
2141 } } // namespace v8::internal | 2148 } } // namespace v8::internal |
OLD | NEW |