| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // invalid/uninitialized position value. | 177 // invalid/uninitialized position value. |
| 178 static const int kNoPosition = -1; | 178 static const int kNoPosition = -1; |
| 179 | 179 |
| 180 enum Mode { | 180 enum Mode { |
| 181 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). | 181 // Please note the order is important (see IsCodeTarget, IsGCRelocMode). |
| 182 CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor. | 182 CONSTRUCT_CALL, // code target that is a call to a JavaScript constructor. |
| 183 CODE_TARGET_CONTEXT, // Code target used for contextual loads. | 183 CODE_TARGET_CONTEXT, // Code target used for contextual loads. |
| 184 DEBUG_BREAK, // Code target for the debugger statement. | 184 DEBUG_BREAK, // Code target for the debugger statement. |
| 185 CODE_TARGET, // Code target which is not any of the above. | 185 CODE_TARGET, // Code target which is not any of the above. |
| 186 EMBEDDED_OBJECT, | 186 EMBEDDED_OBJECT, |
| 187 | |
| 188 GLOBAL_PROPERTY_CELL, | 187 GLOBAL_PROPERTY_CELL, |
| 189 | 188 |
| 190 // Everything after runtime_entry (inclusive) is not GC'ed. | 189 // Everything after runtime_entry (inclusive) is not GC'ed. |
| 191 RUNTIME_ENTRY, | 190 RUNTIME_ENTRY, |
| 192 JS_RETURN, // Marks start of the ExitJSFrame code. | 191 JS_RETURN, // Marks start of the ExitJSFrame code. |
| 193 COMMENT, | 192 COMMENT, |
| 194 POSITION, // See comment for kNoPosition above. | 193 POSITION, // See comment for kNoPosition above. |
| 195 STATEMENT_POSITION, // See comment for kNoPosition above. | 194 STATEMENT_POSITION, // See comment for kNoPosition above. |
| 196 DEBUG_BREAK_SLOT, // Additional code inserted for debug break slot. | 195 DEBUG_BREAK_SLOT, // Additional code inserted for debug break slot. |
| 197 EXTERNAL_REFERENCE, // The address of an external C++ function. | 196 EXTERNAL_REFERENCE, // The address of an external C++ function. |
| 198 INTERNAL_REFERENCE, // An address inside the same function. | 197 INTERNAL_REFERENCE, // An address inside the same function. |
| 199 | 198 |
| 200 // add more as needed | 199 // add more as needed |
| 201 // Pseudo-types | 200 // Pseudo-types |
| 202 NUMBER_OF_MODES, // must be no greater than 14 - see RelocInfoWriter | 201 NUMBER_OF_MODES, // must be no greater than 14 - see RelocInfoWriter |
| 203 NONE, // never recorded | 202 NONE, // never recorded |
| 204 LAST_CODE_ENUM = CODE_TARGET, | 203 LAST_CODE_ENUM = CODE_TARGET, |
| 205 LAST_GCED_ENUM = EMBEDDED_OBJECT | 204 LAST_GCED_ENUM = GLOBAL_PROPERTY_CELL |
| 206 }; | 205 }; |
| 207 | 206 |
| 208 | 207 |
| 209 RelocInfo() {} | 208 RelocInfo() {} |
| 210 RelocInfo(byte* pc, Mode rmode, intptr_t data) | 209 RelocInfo(byte* pc, Mode rmode, intptr_t data) |
| 211 : pc_(pc), rmode_(rmode), data_(data) { | 210 : pc_(pc), rmode_(rmode), data_(data) { |
| 212 } | 211 } |
| 213 | 212 |
| 214 static inline bool IsConstructCall(Mode mode) { | 213 static inline bool IsConstructCall(Mode mode) { |
| 215 return mode == CONSTRUCT_CALL; | 214 return mode == CONSTRUCT_CALL; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 #endif | 458 #endif |
| 460 | 459 |
| 461 | 460 |
| 462 // An ExternalReference represents a C++ address used in the generated | 461 // An ExternalReference represents a C++ address used in the generated |
| 463 // code. All references to C++ functions and variables must be encapsulated in | 462 // code. All references to C++ functions and variables must be encapsulated in |
| 464 // an ExternalReference instance. This is done in order to track the origin of | 463 // an ExternalReference instance. This is done in order to track the origin of |
| 465 // all external references in the code so that they can be bound to the correct | 464 // all external references in the code so that they can be bound to the correct |
| 466 // addresses when deserializing a heap. | 465 // addresses when deserializing a heap. |
| 467 class ExternalReference BASE_EMBEDDED { | 466 class ExternalReference BASE_EMBEDDED { |
| 468 public: | 467 public: |
| 468 // Used in the simulator to support different native api calls. |
| 469 // |
| 470 // BUILTIN_CALL - builtin call. |
| 471 // MaybeObject* f(v8::internal::Arguments). |
| 472 // |
| 473 // FP_RETURN_CALL - builtin call that returns floating point. |
| 474 // double f(double, double). |
| 475 // |
| 476 // DIRECT_CALL - direct call to API function native callback |
| 477 // from generated code. |
| 478 // Handle<Value> f(v8::Arguments&) |
| 479 // |
| 480 enum Type { |
| 481 BUILTIN_CALL, // default |
| 482 FP_RETURN_CALL, |
| 483 DIRECT_CALL |
| 484 }; |
| 485 |
| 486 typedef void* ExternalReferenceRedirector(void* original, Type type); |
| 487 |
| 469 explicit ExternalReference(Builtins::CFunctionId id); | 488 explicit ExternalReference(Builtins::CFunctionId id); |
| 470 | 489 |
| 471 explicit ExternalReference(ApiFunction* ptr); | 490 explicit ExternalReference(ApiFunction* ptr, Type type); |
| 472 | 491 |
| 473 explicit ExternalReference(Builtins::Name name); | 492 explicit ExternalReference(Builtins::Name name); |
| 474 | 493 |
| 475 explicit ExternalReference(Runtime::FunctionId id); | 494 explicit ExternalReference(Runtime::FunctionId id); |
| 476 | 495 |
| 477 explicit ExternalReference(const Runtime::Function* f); | 496 explicit ExternalReference(const Runtime::Function* f); |
| 478 | 497 |
| 479 // Isolate::Current() as an external reference. | |
| 480 static ExternalReference isolate_address(); | |
| 481 | |
| 482 explicit ExternalReference(const IC_Utility& ic_utility); | 498 explicit ExternalReference(const IC_Utility& ic_utility); |
| 483 | 499 |
| 484 #ifdef ENABLE_DEBUGGER_SUPPORT | 500 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 485 explicit ExternalReference(const Debug_Address& debug_address); | 501 explicit ExternalReference(const Debug_Address& debug_address); |
| 486 #endif | 502 #endif |
| 487 | 503 |
| 488 explicit ExternalReference(StatsCounter* counter); | 504 explicit ExternalReference(StatsCounter* counter); |
| 489 | 505 |
| 490 explicit ExternalReference(Isolate::AddressId id); | 506 explicit ExternalReference(Isolate::AddressId id); |
| 491 | 507 |
| 492 explicit ExternalReference(const SCTableReference& table_ref); | 508 explicit ExternalReference(const SCTableReference& table_ref); |
| 493 | 509 |
| 510 // Isolate::Current() as an external reference. |
| 511 static ExternalReference isolate_address(); |
| 512 |
| 494 // One-of-a-kind references. These references are not part of a general | 513 // One-of-a-kind references. These references are not part of a general |
| 495 // pattern. This means that they have to be added to the | 514 // pattern. This means that they have to be added to the |
| 496 // ExternalReferenceTable in serialize.cc manually. | 515 // ExternalReferenceTable in serialize.cc manually. |
| 497 | 516 |
| 498 static ExternalReference perform_gc_function(); | 517 static ExternalReference perform_gc_function(); |
| 499 static ExternalReference fill_heap_number_with_random_function(); | 518 static ExternalReference fill_heap_number_with_random_function(); |
| 500 static ExternalReference random_uint32_function(); | 519 static ExternalReference random_uint32_function(); |
| 501 static ExternalReference transcendental_cache_array_address(); | 520 static ExternalReference transcendental_cache_array_address(); |
| 502 static ExternalReference delete_handle_scope_extensions(); | 521 static ExternalReference delete_handle_scope_extensions(); |
| 503 | 522 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 // byte NativeRegExpMacroAssembler::word_character_bitmap | 603 // byte NativeRegExpMacroAssembler::word_character_bitmap |
| 585 static ExternalReference re_word_character_map(); | 604 static ExternalReference re_word_character_map(); |
| 586 | 605 |
| 587 #endif | 606 #endif |
| 588 | 607 |
| 589 // This lets you register a function that rewrites all external references. | 608 // This lets you register a function that rewrites all external references. |
| 590 // Used by the ARM simulator to catch calls to external references. | 609 // Used by the ARM simulator to catch calls to external references. |
| 591 static void set_redirector(ExternalReferenceRedirector* redirector) { | 610 static void set_redirector(ExternalReferenceRedirector* redirector) { |
| 592 // We can't stack them. | 611 // We can't stack them. |
| 593 ASSERT(Isolate::Current()->external_reference_redirector() == NULL); | 612 ASSERT(Isolate::Current()->external_reference_redirector() == NULL); |
| 594 Isolate::Current()->set_external_reference_redirector(redirector); | 613 Isolate::Current()->set_external_reference_redirector( |
| 614 reinterpret_cast<ExternalReferenceRedirectorPointer*>(redirector)); |
| 595 } | 615 } |
| 596 | 616 |
| 597 private: | 617 private: |
| 598 explicit ExternalReference(void* address) | 618 explicit ExternalReference(void* address) |
| 599 : address_(address) {} | 619 : address_(address) {} |
| 600 | 620 |
| 601 static void* Redirect(void* address, bool fp_return = false) { | 621 static void* Redirect(void* address, |
| 622 Type type = ExternalReference::BUILTIN_CALL) { |
| 602 ExternalReferenceRedirector* redirector = | 623 ExternalReferenceRedirector* redirector = |
| 603 Isolate::Current()->external_reference_redirector(); | 624 reinterpret_cast<ExternalReferenceRedirector*>( |
| 625 Isolate::Current()->external_reference_redirector()); |
| 604 if (redirector == NULL) return address; | 626 if (redirector == NULL) return address; |
| 605 void* answer = (*redirector)(address, fp_return); | 627 void* answer = (*redirector)(address, type); |
| 606 return answer; | 628 return answer; |
| 607 } | 629 } |
| 608 | 630 |
| 609 static void* Redirect(Address address_arg, bool fp_return = false) { | 631 static void* Redirect(Address address_arg, |
| 632 Type type = ExternalReference::BUILTIN_CALL) { |
| 610 ExternalReferenceRedirector* redirector = | 633 ExternalReferenceRedirector* redirector = |
| 611 Isolate::Current()->external_reference_redirector(); | 634 reinterpret_cast<ExternalReferenceRedirector*>( |
| 635 Isolate::Current()->external_reference_redirector()); |
| 612 void* address = reinterpret_cast<void*>(address_arg); | 636 void* address = reinterpret_cast<void*>(address_arg); |
| 613 void* answer = (redirector == NULL) ? | 637 void* answer = (redirector == NULL) ? |
| 614 address : | 638 address : |
| 615 (*redirector)(address, fp_return); | 639 (*redirector)(address, type); |
| 616 return answer; | 640 return answer; |
| 617 } | 641 } |
| 618 | 642 |
| 619 void* address_; | 643 void* address_; |
| 620 }; | 644 }; |
| 621 | 645 |
| 622 | 646 |
| 623 // ----------------------------------------------------------------------------- | 647 // ----------------------------------------------------------------------------- |
| 624 // Position recording support | 648 // Position recording support |
| 625 | 649 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 return num_bits_set; | 771 return num_bits_set; |
| 748 } | 772 } |
| 749 | 773 |
| 750 // Computes pow(x, y) with the special cases in the spec for Math.pow. | 774 // Computes pow(x, y) with the special cases in the spec for Math.pow. |
| 751 double power_double_int(double x, int y); | 775 double power_double_int(double x, int y); |
| 752 double power_double_double(double x, double y); | 776 double power_double_double(double x, double y); |
| 753 | 777 |
| 754 } } // namespace v8::internal | 778 } } // namespace v8::internal |
| 755 | 779 |
| 756 #endif // V8_ASSEMBLER_H_ | 780 #endif // V8_ASSEMBLER_H_ |
| OLD | NEW |