blob: 74613b34274950acf41337c08e36074638eb888f [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001// Copyright (c) 1994-2006 Sun Microsystems Inc.
2// All Rights Reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// - Redistributions of source code must retain the above copyright notice,
9// this list of conditions and the following disclaimer.
10//
11// - Redistribution in binary form must reproduce the above copyright
12// notice, this list of conditions and the following disclaimer in the
13// documentation and/or other materials provided with the distribution.
14//
15// - Neither the name of Sun Microsystems or the names of contributors may
16// be used to endorse or promote products derived from this software without
17// specific prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31// The original source code covered by the above license above has been
32// modified significantly by Google Inc.
33// Copyright 2006-2009 the V8 project authors. All rights reserved.
34
35#ifndef V8_ASSEMBLER_H_
36#define V8_ASSEMBLER_H_
37
38#include "runtime.h"
39#include "top.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000040#include "token.h"
Leon Clarkef7060e22010-06-03 12:02:55 +010041#include "objects.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000042
43namespace v8 {
44namespace internal {
45
46
47// -----------------------------------------------------------------------------
48// Labels represent pc locations; they are typically jump or call targets.
49// After declaration, a label can be freely used to denote known or (yet)
50// unknown pc location. Assembler::bind() is used to bind a label to the
51// current pc. A label can be bound only once.
52
53class Label BASE_EMBEDDED {
54 public:
55 INLINE(Label()) { Unuse(); }
56 INLINE(~Label()) { ASSERT(!is_linked()); }
57
58 INLINE(void Unuse()) { pos_ = 0; }
59
60 INLINE(bool is_bound() const) { return pos_ < 0; }
61 INLINE(bool is_unused() const) { return pos_ == 0; }
62 INLINE(bool is_linked() const) { return pos_ > 0; }
63
64 // Returns the position of bound or linked labels. Cannot be used
65 // for unused labels.
66 int pos() const;
67
68 private:
69 // pos_ encodes both the binding state (via its sign)
70 // and the binding position (via its value) of a label.
71 //
72 // pos_ < 0 bound label, pos() returns the jump target position
73 // pos_ == 0 unused label
74 // pos_ > 0 linked label, pos() returns the last reference position
75 int pos_;
76
77 void bind_to(int pos) {
78 pos_ = -pos - 1;
79 ASSERT(is_bound());
80 }
81 void link_to(int pos) {
82 pos_ = pos + 1;
83 ASSERT(is_linked());
84 }
85
86 friend class Assembler;
87 friend class RegexpAssembler;
88 friend class Displacement;
89 friend class ShadowTarget;
90 friend class RegExpMacroAssemblerIrregexp;
91};
92
93
94// -----------------------------------------------------------------------------
95// Relocation information
96
97
98// Relocation information consists of the address (pc) of the datum
99// to which the relocation information applies, the relocation mode
100// (rmode), and an optional data field. The relocation mode may be
101// "descriptive" and not indicate a need for relocation, but simply
102// describe a property of the datum. Such rmodes are useful for GC
103// and nice disassembly output.
104
105class RelocInfo BASE_EMBEDDED {
106 public:
107 // The constant kNoPosition is used with the collecting of source positions
108 // in the relocation information. Two types of source positions are collected
109 // "position" (RelocMode position) and "statement position" (RelocMode
110 // statement_position). The "position" is collected at places in the source
111 // code which are of interest when making stack traces to pin-point the source
112 // location of a stack frame as close as possible. The "statement position" is
113 // collected at the beginning at each statement, and is used to indicate
114 // possible break locations. kNoPosition is used to indicate an
115 // invalid/uninitialized position value.
116 static const int kNoPosition = -1;
117
118 enum Mode {
119 // Please note the order is important (see IsCodeTarget, IsGCRelocMode).
120 CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor.
121 CODE_TARGET_CONTEXT, // code target used for contextual loads.
Andrei Popescu402d9372010-02-26 13:31:12 +0000122 DEBUG_BREAK,
Steve Blocka7e24c12009-10-30 11:49:00 +0000123 CODE_TARGET, // code target which is not any of the above.
124 EMBEDDED_OBJECT,
Steve Blocka7e24c12009-10-30 11:49:00 +0000125
126 // Everything after runtime_entry (inclusive) is not GC'ed.
127 RUNTIME_ENTRY,
128 JS_RETURN, // Marks start of the ExitJSFrame code.
129 COMMENT,
130 POSITION, // See comment for kNoPosition above.
131 STATEMENT_POSITION, // See comment for kNoPosition above.
132 EXTERNAL_REFERENCE, // The address of an external C++ function.
133 INTERNAL_REFERENCE, // An address inside the same function.
134
135 // add more as needed
136 // Pseudo-types
137 NUMBER_OF_MODES, // must be no greater than 14 - see RelocInfoWriter
138 NONE, // never recorded
139 LAST_CODE_ENUM = CODE_TARGET,
Leon Clarkef7060e22010-06-03 12:02:55 +0100140 LAST_GCED_ENUM = EMBEDDED_OBJECT
Steve Blocka7e24c12009-10-30 11:49:00 +0000141 };
142
143
144 RelocInfo() {}
145 RelocInfo(byte* pc, Mode rmode, intptr_t data)
146 : pc_(pc), rmode_(rmode), data_(data) {
147 }
148
149 static inline bool IsConstructCall(Mode mode) {
150 return mode == CONSTRUCT_CALL;
151 }
152 static inline bool IsCodeTarget(Mode mode) {
153 return mode <= LAST_CODE_ENUM;
154 }
155 // Is the relocation mode affected by GC?
156 static inline bool IsGCRelocMode(Mode mode) {
157 return mode <= LAST_GCED_ENUM;
158 }
159 static inline bool IsJSReturn(Mode mode) {
160 return mode == JS_RETURN;
161 }
162 static inline bool IsComment(Mode mode) {
163 return mode == COMMENT;
164 }
165 static inline bool IsPosition(Mode mode) {
166 return mode == POSITION || mode == STATEMENT_POSITION;
167 }
168 static inline bool IsStatementPosition(Mode mode) {
169 return mode == STATEMENT_POSITION;
170 }
171 static inline bool IsExternalReference(Mode mode) {
172 return mode == EXTERNAL_REFERENCE;
173 }
174 static inline bool IsInternalReference(Mode mode) {
175 return mode == INTERNAL_REFERENCE;
176 }
177 static inline int ModeMask(Mode mode) { return 1 << mode; }
178
179 // Accessors
180 byte* pc() const { return pc_; }
181 void set_pc(byte* pc) { pc_ = pc; }
182 Mode rmode() const { return rmode_; }
183 intptr_t data() const { return data_; }
184
185 // Apply a relocation by delta bytes
186 INLINE(void apply(intptr_t delta));
187
Leon Clarkef7060e22010-06-03 12:02:55 +0100188 // Is the pointer this relocation info refers to coded like a plain pointer
189 // or is it strange in some way (eg relative or patched into a series of
190 // instructions).
191 bool IsCodedSpecially();
192
Steve Blocka7e24c12009-10-30 11:49:00 +0000193 // Read/modify the code target in the branch/call instruction
194 // this relocation applies to;
195 // can only be called if IsCodeTarget(rmode_) || rmode_ == RUNTIME_ENTRY
196 INLINE(Address target_address());
197 INLINE(void set_target_address(Address target));
198 INLINE(Object* target_object());
Steve Block3ce2e202009-11-05 08:53:23 +0000199 INLINE(Handle<Object> target_object_handle(Assembler* origin));
Steve Blocka7e24c12009-10-30 11:49:00 +0000200 INLINE(Object** target_object_address());
201 INLINE(void set_target_object(Object* target));
202
Leon Clarkef7060e22010-06-03 12:02:55 +0100203 // Read the address of the word containing the target_address in an
204 // instruction stream. What this means exactly is architecture-independent.
205 // The only architecture-independent user of this function is the serializer.
206 // The serializer uses it to find out how many raw bytes of instruction to
207 // output before the next target. Architecture-independent code shouldn't
208 // dereference the pointer it gets back from this.
Steve Blocka7e24c12009-10-30 11:49:00 +0000209 INLINE(Address target_address_address());
Leon Clarkef7060e22010-06-03 12:02:55 +0100210 // This indicates how much space a target takes up when deserializing a code
211 // stream. For most architectures this is just the size of a pointer. For
212 // an instruction like movw/movt where the target bits are mixed into the
213 // instruction bits the size of the target will be zero, indicating that the
214 // serializer should not step forwards in memory after a target is resolved
215 // and written. In this case the target_address_address function above
216 // should return the end of the instructions to be patched, allowing the
217 // deserializer to deserialize the instructions as raw bytes and put them in
218 // place, ready to be patched with the target.
219 INLINE(int target_address_size());
Steve Blocka7e24c12009-10-30 11:49:00 +0000220
221 // Read/modify the reference in the instruction this relocation
222 // applies to; can only be called if rmode_ is external_reference
223 INLINE(Address* target_reference_address());
224
225 // Read/modify the address of a call instruction. This is used to relocate
226 // the break points where straight-line code is patched with a call
227 // instruction.
228 INLINE(Address call_address());
229 INLINE(void set_call_address(Address target));
230 INLINE(Object* call_object());
231 INLINE(Object** call_object_address());
232 INLINE(void set_call_object(Object* target));
233
Leon Clarkef7060e22010-06-03 12:02:55 +0100234 inline void Visit(ObjectVisitor* v);
235
Steve Blocka7e24c12009-10-30 11:49:00 +0000236 // Patch the code with some other code.
237 void PatchCode(byte* instructions, int instruction_count);
238
239 // Patch the code with a call.
240 void PatchCodeWithCall(Address target, int guard_bytes);
Steve Block3ce2e202009-11-05 08:53:23 +0000241
242 // Check whether this return sequence has been patched
243 // with a call to the debugger.
244 INLINE(bool IsPatchedReturnSequence());
Steve Blocka7e24c12009-10-30 11:49:00 +0000245
246#ifdef ENABLE_DISASSEMBLER
247 // Printing
248 static const char* RelocModeName(Mode rmode);
249 void Print();
250#endif // ENABLE_DISASSEMBLER
251#ifdef DEBUG
252 // Debugging
253 void Verify();
254#endif
255
256 static const int kCodeTargetMask = (1 << (LAST_CODE_ENUM + 1)) - 1;
257 static const int kPositionMask = 1 << POSITION | 1 << STATEMENT_POSITION;
258 static const int kDebugMask = kPositionMask | 1 << COMMENT;
259 static const int kApplyMask; // Modes affected by apply. Depends on arch.
260
261 private:
262 // On ARM, note that pc_ is the address of the constant pool entry
263 // to be relocated and not the address of the instruction
264 // referencing the constant pool entry (except when rmode_ ==
265 // comment).
266 byte* pc_;
267 Mode rmode_;
268 intptr_t data_;
269 friend class RelocIterator;
270};
271
272
273// RelocInfoWriter serializes a stream of relocation info. It writes towards
274// lower addresses.
275class RelocInfoWriter BASE_EMBEDDED {
276 public:
277 RelocInfoWriter() : pos_(NULL), last_pc_(NULL), last_data_(0) {}
278 RelocInfoWriter(byte* pos, byte* pc) : pos_(pos), last_pc_(pc),
279 last_data_(0) {}
280
281 byte* pos() const { return pos_; }
282 byte* last_pc() const { return last_pc_; }
283
284 void Write(const RelocInfo* rinfo);
285
286 // Update the state of the stream after reloc info buffer
287 // and/or code is moved while the stream is active.
288 void Reposition(byte* pos, byte* pc) {
289 pos_ = pos;
290 last_pc_ = pc;
291 }
292
293 // Max size (bytes) of a written RelocInfo. Longest encoding is
294 // ExtraTag, VariableLengthPCJump, ExtraTag, pc_delta, ExtraTag, data_delta.
295 // On ia32 and arm this is 1 + 4 + 1 + 1 + 1 + 4 = 12.
296 // On x64 this is 1 + 4 + 1 + 1 + 1 + 8 == 16;
297 // Here we use the maximum of the two.
298 static const int kMaxSize = 16;
299
300 private:
301 inline uint32_t WriteVariableLengthPCJump(uint32_t pc_delta);
302 inline void WriteTaggedPC(uint32_t pc_delta, int tag);
303 inline void WriteExtraTaggedPC(uint32_t pc_delta, int extra_tag);
304 inline void WriteExtraTaggedData(intptr_t data_delta, int top_tag);
305 inline void WriteTaggedData(intptr_t data_delta, int tag);
306 inline void WriteExtraTag(int extra_tag, int top_tag);
307
308 byte* pos_;
309 byte* last_pc_;
310 intptr_t last_data_;
311 DISALLOW_COPY_AND_ASSIGN(RelocInfoWriter);
312};
313
314
315// A RelocIterator iterates over relocation information.
316// Typical use:
317//
318// for (RelocIterator it(code); !it.done(); it.next()) {
319// // do something with it.rinfo() here
320// }
321//
322// A mask can be specified to skip unwanted modes.
323class RelocIterator: public Malloced {
324 public:
325 // Create a new iterator positioned at
326 // the beginning of the reloc info.
327 // Relocation information with mode k is included in the
328 // iteration iff bit k of mode_mask is set.
329 explicit RelocIterator(Code* code, int mode_mask = -1);
330 explicit RelocIterator(const CodeDesc& desc, int mode_mask = -1);
331
332 // Iteration
333 bool done() const { return done_; }
334 void next();
335
336 // Return pointer valid until next next().
337 RelocInfo* rinfo() {
338 ASSERT(!done());
339 return &rinfo_;
340 }
341
342 private:
343 // Advance* moves the position before/after reading.
344 // *Read* reads from current byte(s) into rinfo_.
345 // *Get* just reads and returns info on current byte.
346 void Advance(int bytes = 1) { pos_ -= bytes; }
347 int AdvanceGetTag();
348 int GetExtraTag();
349 int GetTopTag();
350 void ReadTaggedPC();
351 void AdvanceReadPC();
352 void AdvanceReadData();
353 void AdvanceReadVariableLengthPCJump();
354 int GetPositionTypeTag();
355 void ReadTaggedData();
356
357 static RelocInfo::Mode DebugInfoModeFromTag(int tag);
358
359 // If the given mode is wanted, set it in rinfo_ and return true.
360 // Else return false. Used for efficiently skipping unwanted modes.
361 bool SetMode(RelocInfo::Mode mode) {
362 return (mode_mask_ & 1 << mode) ? (rinfo_.rmode_ = mode, true) : false;
363 }
364
365 byte* pos_;
366 byte* end_;
367 RelocInfo rinfo_;
368 bool done_;
369 int mode_mask_;
370 DISALLOW_COPY_AND_ASSIGN(RelocIterator);
371};
372
373
374//------------------------------------------------------------------------------
375// External function
376
377//----------------------------------------------------------------------------
378class IC_Utility;
379class SCTableReference;
380#ifdef ENABLE_DEBUGGER_SUPPORT
381class Debug_Address;
382#endif
383
384
385typedef void* ExternalReferenceRedirector(void* original, bool fp_return);
386
387
388// An ExternalReference represents a C++ address used in the generated
389// code. All references to C++ functions and variables must be encapsulated in
390// an ExternalReference instance. This is done in order to track the origin of
391// all external references in the code so that they can be bound to the correct
392// addresses when deserializing a heap.
393class ExternalReference BASE_EMBEDDED {
394 public:
395 explicit ExternalReference(Builtins::CFunctionId id);
396
Steve Blockd0582a62009-12-15 09:54:21 +0000397 explicit ExternalReference(ApiFunction* ptr);
398
Steve Blocka7e24c12009-10-30 11:49:00 +0000399 explicit ExternalReference(Builtins::Name name);
400
401 explicit ExternalReference(Runtime::FunctionId id);
402
403 explicit ExternalReference(Runtime::Function* f);
404
405 explicit ExternalReference(const IC_Utility& ic_utility);
406
407#ifdef ENABLE_DEBUGGER_SUPPORT
408 explicit ExternalReference(const Debug_Address& debug_address);
409#endif
410
411 explicit ExternalReference(StatsCounter* counter);
412
413 explicit ExternalReference(Top::AddressId id);
414
415 explicit ExternalReference(const SCTableReference& table_ref);
416
417 // One-of-a-kind references. These references are not part of a general
418 // pattern. This means that they have to be added to the
419 // ExternalReferenceTable in serialize.cc manually.
420
421 static ExternalReference perform_gc_function();
Steve Block6ded16b2010-05-10 14:33:55 +0100422 static ExternalReference fill_heap_number_with_random_function();
423 static ExternalReference random_uint32_function();
Andrei Popescu402d9372010-02-26 13:31:12 +0000424 static ExternalReference transcendental_cache_array_address();
Steve Blocka7e24c12009-10-30 11:49:00 +0000425
Leon Clarkee46be812010-01-19 14:06:41 +0000426 // Static data in the keyed lookup cache.
427 static ExternalReference keyed_lookup_cache_keys();
428 static ExternalReference keyed_lookup_cache_field_offsets();
429
Steve Blocka7e24c12009-10-30 11:49:00 +0000430 // Static variable Factory::the_hole_value.location()
431 static ExternalReference the_hole_value_location();
432
433 // Static variable Heap::roots_address()
434 static ExternalReference roots_address();
435
436 // Static variable StackGuard::address_of_jslimit()
Steve Blockd0582a62009-12-15 09:54:21 +0000437 static ExternalReference address_of_stack_limit();
438
439 // Static variable StackGuard::address_of_real_jslimit()
440 static ExternalReference address_of_real_stack_limit();
Steve Blocka7e24c12009-10-30 11:49:00 +0000441
442 // Static variable RegExpStack::limit_address()
443 static ExternalReference address_of_regexp_stack_limit();
444
Leon Clarkee46be812010-01-19 14:06:41 +0000445 // Static variables for RegExp.
446 static ExternalReference address_of_static_offsets_vector();
447 static ExternalReference address_of_regexp_stack_memory_address();
448 static ExternalReference address_of_regexp_stack_memory_size();
449
Steve Blocka7e24c12009-10-30 11:49:00 +0000450 // Static variable Heap::NewSpaceStart()
451 static ExternalReference new_space_start();
Andrei Popescu402d9372010-02-26 13:31:12 +0000452 static ExternalReference new_space_mask();
Steve Blocka7e24c12009-10-30 11:49:00 +0000453 static ExternalReference heap_always_allocate_scope_depth();
454
455 // Used for fast allocation in generated code.
456 static ExternalReference new_space_allocation_top_address();
457 static ExternalReference new_space_allocation_limit_address();
458
459 static ExternalReference double_fp_operation(Token::Value operation);
460 static ExternalReference compare_doubles();
461
Steve Blockd0582a62009-12-15 09:54:21 +0000462 static ExternalReference handle_scope_extensions_address();
463 static ExternalReference handle_scope_next_address();
464 static ExternalReference handle_scope_limit_address();
465
466 static ExternalReference scheduled_exception_address();
467
Steve Blocka7e24c12009-10-30 11:49:00 +0000468 Address address() const {return reinterpret_cast<Address>(address_);}
469
470#ifdef ENABLE_DEBUGGER_SUPPORT
471 // Function Debug::Break()
472 static ExternalReference debug_break();
473
474 // Used to check if single stepping is enabled in generated code.
475 static ExternalReference debug_step_in_fp_address();
476#endif
477
Steve Block6ded16b2010-05-10 14:33:55 +0100478#ifndef V8_INTERPRETED_REGEXP
Steve Blocka7e24c12009-10-30 11:49:00 +0000479 // C functions called from RegExp generated code.
480
481 // Function NativeRegExpMacroAssembler::CaseInsensitiveCompareUC16()
482 static ExternalReference re_case_insensitive_compare_uc16();
483
484 // Function RegExpMacroAssembler*::CheckStackGuardState()
485 static ExternalReference re_check_stack_guard_state();
486
487 // Function NativeRegExpMacroAssembler::GrowStack()
488 static ExternalReference re_grow_stack();
Leon Clarkee46be812010-01-19 14:06:41 +0000489
490 // byte NativeRegExpMacroAssembler::word_character_bitmap
491 static ExternalReference re_word_character_map();
492
Steve Blocka7e24c12009-10-30 11:49:00 +0000493#endif
494
495 // This lets you register a function that rewrites all external references.
496 // Used by the ARM simulator to catch calls to external references.
497 static void set_redirector(ExternalReferenceRedirector* redirector) {
498 ASSERT(redirector_ == NULL); // We can't stack them.
499 redirector_ = redirector;
500 }
501
502 private:
503 explicit ExternalReference(void* address)
504 : address_(address) {}
505
506 static ExternalReferenceRedirector* redirector_;
507
508 static void* Redirect(void* address, bool fp_return = false) {
509 if (redirector_ == NULL) return address;
Steve Blockd0582a62009-12-15 09:54:21 +0000510 void* answer = (*redirector_)(address, fp_return);
511 return answer;
Steve Blocka7e24c12009-10-30 11:49:00 +0000512 }
513
514 static void* Redirect(Address address_arg, bool fp_return = false) {
515 void* address = reinterpret_cast<void*>(address_arg);
Steve Blockd0582a62009-12-15 09:54:21 +0000516 void* answer = (redirector_ == NULL) ?
517 address :
518 (*redirector_)(address, fp_return);
519 return answer;
Steve Blocka7e24c12009-10-30 11:49:00 +0000520 }
521
522 void* address_;
523};
524
525
526// -----------------------------------------------------------------------------
527// Utility functions
528
529static inline bool is_intn(int x, int n) {
530 return -(1 << (n-1)) <= x && x < (1 << (n-1));
531}
532
Steve Blocka7e24c12009-10-30 11:49:00 +0000533static inline bool is_int8(int x) { return is_intn(x, 8); }
Andrei Popescu31002712010-02-23 13:46:05 +0000534static inline bool is_int16(int x) { return is_intn(x, 16); }
535static inline bool is_int18(int x) { return is_intn(x, 18); }
536static inline bool is_int24(int x) { return is_intn(x, 24); }
Steve Blocka7e24c12009-10-30 11:49:00 +0000537
538static inline bool is_uintn(int x, int n) {
539 return (x & -(1 << n)) == 0;
540}
541
542static inline bool is_uint2(int x) { return is_uintn(x, 2); }
543static inline bool is_uint3(int x) { return is_uintn(x, 3); }
544static inline bool is_uint4(int x) { return is_uintn(x, 4); }
545static inline bool is_uint5(int x) { return is_uintn(x, 5); }
546static inline bool is_uint6(int x) { return is_uintn(x, 6); }
547static inline bool is_uint8(int x) { return is_uintn(x, 8); }
Andrei Popescu31002712010-02-23 13:46:05 +0000548static inline bool is_uint10(int x) { return is_uintn(x, 10); }
Steve Blocka7e24c12009-10-30 11:49:00 +0000549static inline bool is_uint12(int x) { return is_uintn(x, 12); }
550static inline bool is_uint16(int x) { return is_uintn(x, 16); }
551static inline bool is_uint24(int x) { return is_uintn(x, 24); }
Andrei Popescu31002712010-02-23 13:46:05 +0000552static inline bool is_uint26(int x) { return is_uintn(x, 26); }
553static inline bool is_uint28(int x) { return is_uintn(x, 28); }
554
555static inline int NumberOfBitsSet(uint32_t x) {
556 unsigned int num_bits_set;
557 for (num_bits_set = 0; x; x >>= 1) {
558 num_bits_set += x & 1;
559 }
560 return num_bits_set;
561}
Steve Blocka7e24c12009-10-30 11:49:00 +0000562
563} } // namespace v8::internal
564
565#endif // V8_ASSEMBLER_H_