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 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 //------------------------------------------------------------------------------ | 345 //------------------------------------------------------------------------------ |
346 // External function | 346 // External function |
347 | 347 |
348 //---------------------------------------------------------------------------- | 348 //---------------------------------------------------------------------------- |
349 class IC_Utility; | 349 class IC_Utility; |
350 class SCTableReference; | 350 class SCTableReference; |
351 #ifdef ENABLE_DEBUGGER_SUPPORT | 351 #ifdef ENABLE_DEBUGGER_SUPPORT |
352 class Debug_Address; | 352 class Debug_Address; |
353 #endif | 353 #endif |
354 | 354 |
355 // An ExternalReference represents a C++ address called from the generated | 355 |
356 // code. All references to C++ functions and must be encapsulated in an | 356 typedef void* ExternalReferenceRedirector(void* original, bool fp_return); |
357 // ExternalReference instance. This is done in order to track the origin of | 357 |
358 // all external references in the code. | 358 |
| 359 // An ExternalReference represents a C++ address used in the generated |
| 360 // code. All references to C++ functions and variables must be encapsulated in |
| 361 // an ExternalReference instance. This is done in order to track the origin of |
| 362 // all external references in the code so that they can be bound to the correct |
| 363 // addresses when deserializing a heap. |
359 class ExternalReference BASE_EMBEDDED { | 364 class ExternalReference BASE_EMBEDDED { |
360 public: | 365 public: |
361 explicit ExternalReference(Builtins::CFunctionId id); | 366 explicit ExternalReference(Builtins::CFunctionId id); |
362 | 367 |
363 explicit ExternalReference(Builtins::Name name); | 368 explicit ExternalReference(Builtins::Name name); |
364 | 369 |
365 explicit ExternalReference(Runtime::FunctionId id); | 370 explicit ExternalReference(Runtime::FunctionId id); |
366 | 371 |
367 explicit ExternalReference(Runtime::Function* f); | 372 explicit ExternalReference(Runtime::Function* f); |
368 | 373 |
369 explicit ExternalReference(const IC_Utility& ic_utility); | 374 explicit ExternalReference(const IC_Utility& ic_utility); |
370 | 375 |
371 #ifdef ENABLE_DEBUGGER_SUPPORT | 376 #ifdef ENABLE_DEBUGGER_SUPPORT |
372 explicit ExternalReference(const Debug_Address& debug_address); | 377 explicit ExternalReference(const Debug_Address& debug_address); |
373 #endif | 378 #endif |
374 | 379 |
375 explicit ExternalReference(StatsCounter* counter); | 380 explicit ExternalReference(StatsCounter* counter); |
376 | 381 |
377 explicit ExternalReference(Top::AddressId id); | 382 explicit ExternalReference(Top::AddressId id); |
378 | 383 |
379 explicit ExternalReference(const SCTableReference& table_ref); | 384 explicit ExternalReference(const SCTableReference& table_ref); |
380 | 385 |
381 // One-of-a-kind references. These references are not part of a general | 386 // One-of-a-kind references. These references are not part of a general |
382 // pattern. This means that they have to be added to the | 387 // pattern. This means that they have to be added to the |
383 // ExternalReferenceTable in serialize.cc manually. | 388 // ExternalReferenceTable in serialize.cc manually. |
384 | 389 |
| 390 static ExternalReference perform_gc_function(); |
| 391 |
385 static ExternalReference builtin_passed_function(); | 392 static ExternalReference builtin_passed_function(); |
386 | 393 |
387 // Static variable Factory::the_hole_value.location() | 394 // Static variable Factory::the_hole_value.location() |
388 static ExternalReference the_hole_value_location(); | 395 static ExternalReference the_hole_value_location(); |
389 | 396 |
390 // Static variable StackGuard::address_of_jslimit() | 397 // Static variable StackGuard::address_of_jslimit() |
391 static ExternalReference address_of_stack_guard_limit(); | 398 static ExternalReference address_of_stack_guard_limit(); |
392 | 399 |
393 // Static variable RegExpStack::limit_address() | 400 // Static variable RegExpStack::limit_address() |
394 static ExternalReference address_of_regexp_stack_limit(); | 401 static ExternalReference address_of_regexp_stack_limit(); |
395 | 402 |
396 // Static variable Heap::NewSpaceStart() | 403 // Static variable Heap::NewSpaceStart() |
397 static ExternalReference new_space_start(); | 404 static ExternalReference new_space_start(); |
398 static ExternalReference heap_always_allocate_scope_depth(); | 405 static ExternalReference heap_always_allocate_scope_depth(); |
399 | 406 |
400 // Used for fast allocation in generated code. | 407 // Used for fast allocation in generated code. |
401 static ExternalReference new_space_allocation_top_address(); | 408 static ExternalReference new_space_allocation_top_address(); |
402 static ExternalReference new_space_allocation_limit_address(); | 409 static ExternalReference new_space_allocation_limit_address(); |
403 | 410 |
404 static ExternalReference double_fp_operation(Token::Value operation); | 411 static ExternalReference double_fp_operation(Token::Value operation); |
405 | 412 |
406 Address address() const {return address_;} | 413 Address address() const {return reinterpret_cast<Address>(address_);} |
407 | 414 |
408 #ifdef ENABLE_DEBUGGER_SUPPORT | 415 #ifdef ENABLE_DEBUGGER_SUPPORT |
409 // Function Debug::Break() | 416 // Function Debug::Break() |
410 static ExternalReference debug_break(); | 417 static ExternalReference debug_break(); |
411 | 418 |
412 // Used to check if single stepping is enabled in generated code. | 419 // Used to check if single stepping is enabled in generated code. |
413 static ExternalReference debug_step_in_fp_address(); | 420 static ExternalReference debug_step_in_fp_address(); |
414 #endif | 421 #endif |
415 | 422 |
| 423 // This lets you register a function that rewrites all external references. |
| 424 // Used by the ARM simulator to catch calls to external references. |
| 425 static void set_redirector(ExternalReferenceRedirector* redirector) { |
| 426 ASSERT(redirector_ == NULL); // We can't stack them. |
| 427 redirector_ = redirector; |
| 428 } |
| 429 |
416 private: | 430 private: |
417 explicit ExternalReference(void* address) | 431 explicit ExternalReference(void* address) |
418 : address_(reinterpret_cast<Address>(address)) {} | 432 : address_(address) {} |
419 | 433 |
420 Address address_; | 434 static ExternalReferenceRedirector* redirector_; |
| 435 |
| 436 static void* Redirect(void* address, bool fp_return = false) { |
| 437 if (redirector_ == NULL) return address; |
| 438 return (*redirector_)(address, fp_return); |
| 439 } |
| 440 |
| 441 static void* Redirect(Address address_arg, bool fp_return = false) { |
| 442 void* address = reinterpret_cast<void*>(address_arg); |
| 443 return redirector_ == NULL ? address : (*redirector_)(address, fp_return); |
| 444 } |
| 445 |
| 446 void* address_; |
421 }; | 447 }; |
422 | 448 |
423 | 449 |
424 // ----------------------------------------------------------------------------- | 450 // ----------------------------------------------------------------------------- |
425 // Utility functions | 451 // Utility functions |
426 | 452 |
427 // Move these into inline file? | 453 // Move these into inline file? |
428 | 454 |
429 static inline bool is_intn(int x, int n) { | 455 static inline bool is_intn(int x, int n) { |
430 return -(1 << (n-1)) <= x && x < (1 << (n-1)); | 456 return -(1 << (n-1)) <= x && x < (1 << (n-1)); |
(...skipping 10 matching lines...) Expand all Loading... |
441 static inline bool is_uint4(int x) { return is_uintn(x, 4); } | 467 static inline bool is_uint4(int x) { return is_uintn(x, 4); } |
442 static inline bool is_uint5(int x) { return is_uintn(x, 5); } | 468 static inline bool is_uint5(int x) { return is_uintn(x, 5); } |
443 static inline bool is_uint8(int x) { return is_uintn(x, 8); } | 469 static inline bool is_uint8(int x) { return is_uintn(x, 8); } |
444 static inline bool is_uint12(int x) { return is_uintn(x, 12); } | 470 static inline bool is_uint12(int x) { return is_uintn(x, 12); } |
445 static inline bool is_uint16(int x) { return is_uintn(x, 16); } | 471 static inline bool is_uint16(int x) { return is_uintn(x, 16); } |
446 static inline bool is_uint24(int x) { return is_uintn(x, 24); } | 472 static inline bool is_uint24(int x) { return is_uintn(x, 24); } |
447 | 473 |
448 } } // namespace v8::internal | 474 } } // namespace v8::internal |
449 | 475 |
450 #endif // V8_ASSEMBLER_H_ | 476 #endif // V8_ASSEMBLER_H_ |
OLD | NEW |