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

Side by Side Diff: src/runtime.h

Issue 6880010: Merge (7265, 7271] from bleeding_edge to experimental/gc branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 8 months 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_RUNTIME_H_ 28 #ifndef V8_RUNTIME_H_
29 #define V8_RUNTIME_H_ 29 #define V8_RUNTIME_H_
30 30
31 #include "zone.h"
32
31 namespace v8 { 33 namespace v8 {
32 namespace internal { 34 namespace internal {
33 35
34 // The interface to C++ runtime functions. 36 // The interface to C++ runtime functions.
35 37
36 // ---------------------------------------------------------------------------- 38 // ----------------------------------------------------------------------------
37 // RUNTIME_FUNCTION_LIST_ALWAYS defines runtime calls available in both 39 // RUNTIME_FUNCTION_LIST_ALWAYS defines runtime calls available in both
38 // release and debug mode. 40 // release and debug mode.
39 // This macro should only be used by the macro RUNTIME_FUNCTION_LIST. 41 // This macro should only be used by the macro RUNTIME_FUNCTION_LIST.
40 42
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 F(GetConstructorDelegate, 1, 1) \ 81 F(GetConstructorDelegate, 1, 1) \
80 F(NewArgumentsFast, 3, 1) \ 82 F(NewArgumentsFast, 3, 1) \
81 F(LazyCompile, 1, 1) \ 83 F(LazyCompile, 1, 1) \
82 F(LazyRecompile, 1, 1) \ 84 F(LazyRecompile, 1, 1) \
83 F(NotifyDeoptimized, 1, 1) \ 85 F(NotifyDeoptimized, 1, 1) \
84 F(NotifyOSR, 0, 1) \ 86 F(NotifyOSR, 0, 1) \
85 F(DeoptimizeFunction, 1, 1) \ 87 F(DeoptimizeFunction, 1, 1) \
86 F(CompileForOnStackReplacement, 1, 1) \ 88 F(CompileForOnStackReplacement, 1, 1) \
87 F(SetNewFunctionAttributes, 1, 1) \ 89 F(SetNewFunctionAttributes, 1, 1) \
88 F(AllocateInNewSpace, 1, 1) \ 90 F(AllocateInNewSpace, 1, 1) \
89 F(StoreBufferOverflow, 0, 1) \
90 \ 91 \
91 /* Array join support */ \ 92 /* Array join support */ \
92 F(PushIfAbsent, 2, 1) \ 93 F(PushIfAbsent, 2, 1) \
93 F(ArrayConcat, 1, 1) \ 94 F(ArrayConcat, 1, 1) \
94 \ 95 \
95 /* Conversions */ \ 96 /* Conversions */ \
96 F(ToBool, 1, 1) \ 97 F(ToBool, 1, 1) \
97 F(Typeof, 1, 1) \ 98 F(Typeof, 1, 1) \
98 \ 99 \
99 F(StringToNumber, 1, 1) \ 100 F(StringToNumber, 1, 1) \
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 #endif 407 #endif
407 408
408 #ifdef DEBUG 409 #ifdef DEBUG
409 #define RUNTIME_FUNCTION_LIST_DEBUG(F) \ 410 #define RUNTIME_FUNCTION_LIST_DEBUG(F) \
410 /* Testing */ \ 411 /* Testing */ \
411 F(ListNatives, 0, 1) 412 F(ListNatives, 0, 1)
412 #else 413 #else
413 #define RUNTIME_FUNCTION_LIST_DEBUG(F) 414 #define RUNTIME_FUNCTION_LIST_DEBUG(F)
414 #endif 415 #endif
415 416
416
417 // ---------------------------------------------------------------------------- 417 // ----------------------------------------------------------------------------
418 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed 418 // RUNTIME_FUNCTION_LIST defines all runtime functions accessed
419 // either directly by id (via the code generator), or indirectly 419 // either directly by id (via the code generator), or indirectly
420 // via a native call by name (from within JS code). 420 // via a native call by name (from within JS code).
421 421
422 #define RUNTIME_FUNCTION_LIST(F) \ 422 #define RUNTIME_FUNCTION_LIST(F) \
423 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \ 423 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
424 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ 424 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
425 RUNTIME_FUNCTION_LIST_DEBUG(F) \ 425 RUNTIME_FUNCTION_LIST_DEBUG(F) \
426 RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \ 426 RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 F(RegExpExec, 4, 1) \ 476 F(RegExpExec, 4, 1) \
477 F(RegExpConstructResult, 3, 1) \ 477 F(RegExpConstructResult, 3, 1) \
478 F(GetFromCache, 2, 1) \ 478 F(GetFromCache, 2, 1) \
479 F(NumberToString, 1, 1) \ 479 F(NumberToString, 1, 1) \
480 F(SwapElements, 3, 1) 480 F(SwapElements, 3, 1)
481 481
482 482
483 //--------------------------------------------------------------------------- 483 //---------------------------------------------------------------------------
484 // Runtime provides access to all C++ runtime functions. 484 // Runtime provides access to all C++ runtime functions.
485 485
486 class RuntimeState {
487 public:
488
489 StaticResource<StringInputBuffer>* string_input_buffer() {
490 return &string_input_buffer_;
491 }
492 unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() {
493 return &to_upper_mapping_;
494 }
495 unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() {
496 return &to_lower_mapping_;
497 }
498 StringInputBuffer* string_input_buffer_compare_bufx() {
499 return &string_input_buffer_compare_bufx_;
500 }
501 StringInputBuffer* string_input_buffer_compare_bufy() {
502 return &string_input_buffer_compare_bufy_;
503 }
504 StringInputBuffer* string_locale_compare_buf1() {
505 return &string_locale_compare_buf1_;
506 }
507 StringInputBuffer* string_locale_compare_buf2() {
508 return &string_locale_compare_buf2_;
509 }
510 int* smi_lexicographic_compare_x_elms() {
511 return smi_lexicographic_compare_x_elms_;
512 }
513 int* smi_lexicographic_compare_y_elms() {
514 return smi_lexicographic_compare_y_elms_;
515 }
516
517 private:
518 RuntimeState() {}
519 // Non-reentrant string buffer for efficient general use in the runtime.
520 StaticResource<StringInputBuffer> string_input_buffer_;
521 unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_;
522 unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_;
523 StringInputBuffer string_input_buffer_compare_bufx_;
524 StringInputBuffer string_input_buffer_compare_bufy_;
525 StringInputBuffer string_locale_compare_buf1_;
526 StringInputBuffer string_locale_compare_buf2_;
527 int smi_lexicographic_compare_x_elms_[10];
528 int smi_lexicographic_compare_y_elms_[10];
529
530 friend class Isolate;
531 friend class Runtime;
532
533 DISALLOW_COPY_AND_ASSIGN(RuntimeState);
534 };
535
536
486 class Runtime : public AllStatic { 537 class Runtime : public AllStatic {
487 public: 538 public:
488 enum FunctionId { 539 enum FunctionId {
489 #define F(name, nargs, ressize) k##name, 540 #define F(name, nargs, ressize) k##name,
490 RUNTIME_FUNCTION_LIST(F) 541 RUNTIME_FUNCTION_LIST(F)
491 #undef F 542 #undef F
492 #define F(name, nargs, ressize) kInline##name, 543 #define F(name, nargs, ressize) kInline##name,
493 INLINE_FUNCTION_LIST(F) 544 INLINE_FUNCTION_LIST(F)
494 INLINE_RUNTIME_FUNCTION_LIST(F) 545 INLINE_RUNTIME_FUNCTION_LIST(F)
495 #undef F 546 #undef F
(...skipping 23 matching lines...) Expand all
519 int result_size; 570 int result_size;
520 }; 571 };
521 572
522 static const int kNotFound = -1; 573 static const int kNotFound = -1;
523 574
524 // Add symbols for all the intrinsic function names to a StringDictionary. 575 // Add symbols for all the intrinsic function names to a StringDictionary.
525 // Returns failure if an allocation fails. In this case, it must be 576 // Returns failure if an allocation fails. In this case, it must be
526 // retried with a new, empty StringDictionary, not with the same one. 577 // retried with a new, empty StringDictionary, not with the same one.
527 // Alternatively, heap initialization can be completely restarted. 578 // Alternatively, heap initialization can be completely restarted.
528 MUST_USE_RESULT static MaybeObject* InitializeIntrinsicFunctionNames( 579 MUST_USE_RESULT static MaybeObject* InitializeIntrinsicFunctionNames(
529 Object* dictionary); 580 Heap* heap, Object* dictionary);
530 581
531 // Get the intrinsic function with the given name, which must be a symbol. 582 // Get the intrinsic function with the given name, which must be a symbol.
532 static Function* FunctionForSymbol(Handle<String> name); 583 static const Function* FunctionForSymbol(Handle<String> name);
533 584
534 // Get the intrinsic function with the given FunctionId. 585 // Get the intrinsic function with the given FunctionId.
535 static Function* FunctionForId(FunctionId id); 586 static const Function* FunctionForId(FunctionId id);
536 587
537 // General-purpose helper functions for runtime system. 588 // General-purpose helper functions for runtime system.
538 static int StringMatch(Handle<String> sub, Handle<String> pat, int index); 589 static int StringMatch(Isolate* isolate,
590 Handle<String> sub,
591 Handle<String> pat,
592 int index);
539 593
540 static bool IsUpperCaseChar(uint16_t ch); 594 static bool IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch);
541 595
542 // TODO(1240886): The following three methods are *not* handle safe, 596 // TODO(1240886): The following three methods are *not* handle safe,
543 // but accept handle arguments. This seems fragile. 597 // but accept handle arguments. This seems fragile.
544 598
545 // Support getting the characters in a string using [] notation as 599 // Support getting the characters in a string using [] notation as
546 // in Firefox/SpiderMonkey, Safari and Opera. 600 // in Firefox/SpiderMonkey, Safari and Opera.
547 MUST_USE_RESULT static MaybeObject* GetElementOrCharAt(Handle<Object> object, 601 MUST_USE_RESULT static MaybeObject* GetElementOrCharAt(Isolate* isolate,
602 Handle<Object> object,
548 uint32_t index); 603 uint32_t index);
549 MUST_USE_RESULT static MaybeObject* GetElement(Handle<Object> object, 604 MUST_USE_RESULT static MaybeObject* GetElement(Handle<Object> object,
550 uint32_t index); 605 uint32_t index);
551 606
552 MUST_USE_RESULT static MaybeObject* SetObjectProperty( 607 MUST_USE_RESULT static MaybeObject* SetObjectProperty(
608 Isolate* isolate,
553 Handle<Object> object, 609 Handle<Object> object,
554 Handle<Object> key, 610 Handle<Object> key,
555 Handle<Object> value, 611 Handle<Object> value,
556 PropertyAttributes attr, 612 PropertyAttributes attr,
557 StrictModeFlag strict_mode); 613 StrictModeFlag strict_mode);
558 614
559 MUST_USE_RESULT static MaybeObject* ForceSetObjectProperty( 615 MUST_USE_RESULT static MaybeObject* ForceSetObjectProperty(
616 Isolate* isolate,
560 Handle<JSObject> object, 617 Handle<JSObject> object,
561 Handle<Object> key, 618 Handle<Object> key,
562 Handle<Object> value, 619 Handle<Object> value,
563 PropertyAttributes attr); 620 PropertyAttributes attr);
564 621
565 MUST_USE_RESULT static MaybeObject* ForceDeleteObjectProperty( 622 MUST_USE_RESULT static MaybeObject* ForceDeleteObjectProperty(
623 Isolate* isolate,
566 Handle<JSObject> object, 624 Handle<JSObject> object,
567 Handle<Object> key); 625 Handle<Object> key);
568 626
569 MUST_USE_RESULT static MaybeObject* GetObjectProperty(Handle<Object> object, 627 MUST_USE_RESULT static MaybeObject* GetObjectProperty(
570 Handle<Object> key); 628 Isolate* isolate,
629 Handle<Object> object,
630 Handle<Object> key);
571 631
572 // This function is used in FunctionNameUsing* tests. 632 // This function is used in FunctionNameUsing* tests.
573 static Object* FindSharedFunctionInfoInScript(Handle<Script> script, 633 static Object* FindSharedFunctionInfoInScript(Isolate* isolate,
634 Handle<Script> script,
574 int position); 635 int position);
575 636
576 // Helper functions used stubs. 637 // Helper functions used stubs.
577 static void PerformGC(Object* result); 638 static void PerformGC(Object* result);
578 }; 639 };
579 640
580
581 } } // namespace v8::internal 641 } } // namespace v8::internal
582 642
583 #endif // V8_RUNTIME_H_ 643 #endif // V8_RUNTIME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698