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

Side by Side Diff: src/assembler.cc

Issue 9976003: Minimize uses of lazy initialization by adding explicit initialization functions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address Daniel's comments. Created 8 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
« no previous file with comments | « src/assembler.h ('k') | src/frames.h » ('j') | src/v8.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 double min_int; 92 double min_int;
93 double one_half; 93 double one_half;
94 double minus_zero; 94 double minus_zero;
95 double zero; 95 double zero;
96 double uint8_max_value; 96 double uint8_max_value;
97 double negative_infinity; 97 double negative_infinity;
98 double canonical_non_hole_nan; 98 double canonical_non_hole_nan;
99 double the_hole_nan; 99 double the_hole_nan;
100 }; 100 };
101 101
102 struct InitializeDoubleConstants { 102 static DoubleConstant double_constants;
103 static void Construct(DoubleConstant* double_constants) {
104 double_constants->min_int = kMinInt;
105 double_constants->one_half = 0.5;
106 double_constants->minus_zero = -0.0;
107 double_constants->uint8_max_value = 255;
108 double_constants->zero = 0.0;
109 double_constants->canonical_non_hole_nan = OS::nan_value();
110 double_constants->the_hole_nan = BitCast<double>(kHoleNanInt64);
111 double_constants->negative_infinity = -V8_INFINITY;
112 }
113 };
114
115 static LazyInstance<DoubleConstant, InitializeDoubleConstants>::type
116 double_constants = LAZY_INSTANCE_INITIALIZER;
117 103
118 const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING"; 104 const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING";
119 105
120 // ----------------------------------------------------------------------------- 106 // -----------------------------------------------------------------------------
121 // Implementation of AssemblerBase 107 // Implementation of AssemblerBase
122 108
123 AssemblerBase::AssemblerBase(Isolate* isolate) 109 AssemblerBase::AssemblerBase(Isolate* isolate)
124 : isolate_(isolate), 110 : isolate_(isolate),
125 jit_cookie_(0) { 111 jit_cookie_(0) {
126 if (FLAG_mask_constants_with_cookie && isolate != NULL) { 112 if (FLAG_mask_constants_with_cookie && isolate != NULL) {
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 UNREACHABLE(); 705 UNREACHABLE();
720 break; 706 break;
721 } 707 }
722 } 708 }
723 #endif // DEBUG 709 #endif // DEBUG
724 710
725 711
726 // ----------------------------------------------------------------------------- 712 // -----------------------------------------------------------------------------
727 // Implementation of ExternalReference 713 // Implementation of ExternalReference
728 714
715 void ExternalReference::SetUp() {
716 double_constants.min_int = kMinInt;
717 double_constants.one_half = 0.5;
718 double_constants.minus_zero = -0.0;
719 double_constants.uint8_max_value = 255;
720 double_constants.zero = 0.0;
721 double_constants.canonical_non_hole_nan = OS::nan_value();
722 double_constants.the_hole_nan = BitCast<double>(kHoleNanInt64);
723 double_constants.negative_infinity = -V8_INFINITY;
724 }
725
726
729 ExternalReference::ExternalReference(Builtins::CFunctionId id, Isolate* isolate) 727 ExternalReference::ExternalReference(Builtins::CFunctionId id, Isolate* isolate)
730 : address_(Redirect(isolate, Builtins::c_function_address(id))) {} 728 : address_(Redirect(isolate, Builtins::c_function_address(id))) {}
731 729
732 730
733 ExternalReference::ExternalReference( 731 ExternalReference::ExternalReference(
734 ApiFunction* fun, 732 ApiFunction* fun,
735 Type type = ExternalReference::BUILTIN_CALL, 733 Type type = ExternalReference::BUILTIN_CALL,
736 Isolate* isolate = NULL) 734 Isolate* isolate = NULL)
737 : address_(Redirect(isolate, fun->address(), type)) {} 735 : address_(Redirect(isolate, fun->address(), type)) {}
738 736
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 } 949 }
952 950
953 951
954 ExternalReference ExternalReference::scheduled_exception_address( 952 ExternalReference ExternalReference::scheduled_exception_address(
955 Isolate* isolate) { 953 Isolate* isolate) {
956 return ExternalReference(isolate->scheduled_exception_address()); 954 return ExternalReference(isolate->scheduled_exception_address());
957 } 955 }
958 956
959 957
960 ExternalReference ExternalReference::address_of_min_int() { 958 ExternalReference ExternalReference::address_of_min_int() {
961 return ExternalReference(reinterpret_cast<void*>( 959 return ExternalReference(reinterpret_cast<void*>(&double_constants.min_int));
962 &double_constants.Pointer()->min_int));
963 } 960 }
964 961
965 962
966 ExternalReference ExternalReference::address_of_one_half() { 963 ExternalReference ExternalReference::address_of_one_half() {
967 return ExternalReference(reinterpret_cast<void*>( 964 return ExternalReference(reinterpret_cast<void*>(&double_constants.one_half));
968 &double_constants.Pointer()->one_half));
969 } 965 }
970 966
971 967
972 ExternalReference ExternalReference::address_of_minus_zero() { 968 ExternalReference ExternalReference::address_of_minus_zero() {
973 return ExternalReference(reinterpret_cast<void*>( 969 return ExternalReference(
974 &double_constants.Pointer()->minus_zero)); 970 reinterpret_cast<void*>(&double_constants.minus_zero));
975 } 971 }
976 972
977 973
978 ExternalReference ExternalReference::address_of_zero() { 974 ExternalReference ExternalReference::address_of_zero() {
979 return ExternalReference(reinterpret_cast<void*>( 975 return ExternalReference(reinterpret_cast<void*>(&double_constants.zero));
980 &double_constants.Pointer()->zero));
981 } 976 }
982 977
983 978
984 ExternalReference ExternalReference::address_of_uint8_max_value() { 979 ExternalReference ExternalReference::address_of_uint8_max_value() {
985 return ExternalReference(reinterpret_cast<void*>( 980 return ExternalReference(
986 &double_constants.Pointer()->uint8_max_value)); 981 reinterpret_cast<void*>(&double_constants.uint8_max_value));
987 } 982 }
988 983
989 984
990 ExternalReference ExternalReference::address_of_negative_infinity() { 985 ExternalReference ExternalReference::address_of_negative_infinity() {
991 return ExternalReference(reinterpret_cast<void*>( 986 return ExternalReference(
992 &double_constants.Pointer()->negative_infinity)); 987 reinterpret_cast<void*>(&double_constants.negative_infinity));
993 } 988 }
994 989
995 990
996 ExternalReference ExternalReference::address_of_canonical_non_hole_nan() { 991 ExternalReference ExternalReference::address_of_canonical_non_hole_nan() {
997 return ExternalReference(reinterpret_cast<void*>( 992 return ExternalReference(
998 &double_constants.Pointer()->canonical_non_hole_nan)); 993 reinterpret_cast<void*>(&double_constants.canonical_non_hole_nan));
999 } 994 }
1000 995
1001 996
1002 ExternalReference ExternalReference::address_of_the_hole_nan() { 997 ExternalReference ExternalReference::address_of_the_hole_nan() {
1003 return ExternalReference(reinterpret_cast<void*>( 998 return ExternalReference(
1004 &double_constants.Pointer()->the_hole_nan)); 999 reinterpret_cast<void*>(&double_constants.the_hole_nan));
1005 } 1000 }
1006 1001
1007 1002
1008 #ifndef V8_INTERPRETED_REGEXP 1003 #ifndef V8_INTERPRETED_REGEXP
1009 1004
1010 ExternalReference ExternalReference::re_check_stack_guard_state( 1005 ExternalReference ExternalReference::re_check_stack_guard_state(
1011 Isolate* isolate) { 1006 Isolate* isolate) {
1012 Address function; 1007 Address function;
1013 #ifdef V8_TARGET_ARCH_X64 1008 #ifdef V8_TARGET_ARCH_X64
1014 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState); 1009 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); 1293 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position);
1299 state_.written_position = state_.current_position; 1294 state_.written_position = state_.current_position;
1300 written = true; 1295 written = true;
1301 } 1296 }
1302 1297
1303 // Return whether something was written. 1298 // Return whether something was written.
1304 return written; 1299 return written;
1305 } 1300 }
1306 1301
1307 } } // namespace v8::internal 1302 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | src/frames.h » ('j') | src/v8.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698