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

Side by Side Diff: src/api.cc

Issue 6580038: [Isolates] Merge from bleeding_edge, revisions 5934-6100. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 10 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/allocation.h ('k') | src/arm/code-stubs-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 EnsureConstructor(this); 1186 EnsureConstructor(this);
1187 } 1187 }
1188 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value)); 1188 Utils::OpenHandle(this)->set_internal_field_count(i::Smi::FromInt(value));
1189 } 1189 }
1190 1190
1191 1191
1192 // --- S c r i p t D a t a --- 1192 // --- S c r i p t D a t a ---
1193 1193
1194 1194
1195 ScriptData* ScriptData::PreCompile(const char* input, int length) { 1195 ScriptData* ScriptData::PreCompile(const char* input, int length) {
1196 unibrow::Utf8InputBuffer<> buf(input, length); 1196 i::Utf8ToUC16CharacterStream stream(
1197 return i::ParserApi::PreParse(i::Handle<i::String>(), &buf, NULL); 1197 reinterpret_cast<const unsigned char*>(input), length);
1198 return i::ParserApi::PreParse(&stream, NULL);
1198 } 1199 }
1199 1200
1200 1201
1201 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) { 1202 ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
1202 i::Handle<i::String> str = Utils::OpenHandle(*source); 1203 i::Handle<i::String> str = Utils::OpenHandle(*source);
1203 return i::ParserApi::PreParse(str, NULL, NULL); 1204 if (str->IsExternalTwoByteString()) {
1205 i::ExternalTwoByteStringUC16CharacterStream stream(
1206 i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
1207 return i::ParserApi::PreParse(&stream, NULL);
1208 } else {
1209 i::GenericStringUC16CharacterStream stream(str, 0, str->length());
1210 return i::ParserApi::PreParse(&stream, NULL);
1211 }
1204 } 1212 }
1205 1213
1206 1214
1207 ScriptData* ScriptData::New(const char* data, int length) { 1215 ScriptData* ScriptData::New(const char* data, int length) {
1208 // Return an empty ScriptData if the length is obviously invalid. 1216 // Return an empty ScriptData if the length is obviously invalid.
1209 if (length % sizeof(unsigned) != 0) { 1217 if (length % sizeof(unsigned) != 0) {
1210 return new i::ScriptDataImpl(); 1218 return new i::ScriptDataImpl();
1211 } 1219 }
1212 1220
1213 // Copy the data to ensure it is properly aligned. 1221 // Copy the data to ensure it is properly aligned.
(...skipping 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after
3081 LOG_API("String::Write"); 3089 LOG_API("String::Write");
3082 ENTER_V8; 3090 ENTER_V8;
3083 ASSERT(start >= 0 && length >= -1); 3091 ASSERT(start >= 0 && length >= -1);
3084 i::Handle<i::String> str = Utils::OpenHandle(this); 3092 i::Handle<i::String> str = Utils::OpenHandle(this);
3085 i::Isolate::Current()->string_tracker()->RecordWrite(str); 3093 i::Isolate::Current()->string_tracker()->RecordWrite(str);
3086 if (hints & HINT_MANY_WRITES_EXPECTED) { 3094 if (hints & HINT_MANY_WRITES_EXPECTED) {
3087 // Flatten the string for efficiency. This applies whether we are 3095 // Flatten the string for efficiency. This applies whether we are
3088 // using StringInputBuffer or Get(i) to access the characters. 3096 // using StringInputBuffer or Get(i) to access the characters.
3089 str->TryFlatten(); 3097 str->TryFlatten();
3090 } 3098 }
3091 int end = length; 3099 int end = start + length;
3092 if ( (length == -1) || (length > str->length() - start) ) 3100 if ((length == -1) || (length > str->length() - start) )
3093 end = str->length() - start; 3101 end = str->length();
3094 if (end < 0) return 0; 3102 if (end < 0) return 0;
3095 i::String::WriteToFlat(*str, buffer, start, end); 3103 i::String::WriteToFlat(*str, buffer, start, end);
3096 if (length == -1 || end < length) 3104 if (length == -1 || end - start < length) {
3097 buffer[end] = '\0'; 3105 buffer[end - start] = '\0';
3098 return end; 3106 }
3107 return end - start;
3099 } 3108 }
3100 3109
3101 3110
3102 bool v8::String::IsExternal() const { 3111 bool v8::String::IsExternal() const {
3103 EnsureInitialized("v8::String::IsExternal()"); 3112 EnsureInitialized("v8::String::IsExternal()");
3104 i::Handle<i::String> str = Utils::OpenHandle(this); 3113 i::Handle<i::String> str = Utils::OpenHandle(this);
3105 return i::StringShape(*str).IsExternalTwoByte(); 3114 return i::StringShape(*str).IsExternalTwoByte();
3106 } 3115 }
3107 3116
3108 3117
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
3771 3780
3772 double v8::Date::NumberValue() const { 3781 double v8::Date::NumberValue() const {
3773 if (IsDeadCheck("v8::Date::NumberValue()")) return 0; 3782 if (IsDeadCheck("v8::Date::NumberValue()")) return 0;
3774 LOG_API("Date::NumberValue"); 3783 LOG_API("Date::NumberValue");
3775 i::Handle<i::Object> obj = Utils::OpenHandle(this); 3784 i::Handle<i::Object> obj = Utils::OpenHandle(this);
3776 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 3785 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
3777 return jsvalue->value()->Number(); 3786 return jsvalue->value()->Number();
3778 } 3787 }
3779 3788
3780 3789
3790 void v8::Date::DateTimeConfigurationChangeNotification() {
3791 ON_BAILOUT("v8::Date::DateTimeConfigurationChangeNotification()", return);
3792 LOG_API("Date::DateTimeConfigurationChangeNotification");
3793 ENTER_V8;
3794
3795 HandleScope scope;
3796 i::Isolate* isolate = i::Isolate::Current();
3797 // Get the function ResetDateCache (defined in date-delay.js).
3798 i::Handle<i::String> func_name_str =
3799 isolate->factory()->LookupAsciiSymbol("ResetDateCache");
3800 i::MaybeObject* result =
3801 isolate->js_builtins_object()->GetProperty(*func_name_str);
3802 i::Object* object_func;
3803 if (!result->ToObject(&object_func)) {
3804 return;
3805 }
3806
3807 if (object_func->IsJSFunction()) {
3808 i::Handle<i::JSFunction> func =
3809 i::Handle<i::JSFunction>(i::JSFunction::cast(object_func));
3810
3811 // Call ResetDateCache(0 but expect no exceptions:
3812 bool caught_exception = false;
3813 i::Handle<i::Object> result =
3814 i::Execution::TryCall(func, isolate->js_builtins_object(), 0, NULL,
3815 &caught_exception);
3816 }
3817 }
3818
3819
3781 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { 3820 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) {
3782 char flags_buf[3]; 3821 char flags_buf[3];
3783 int num_flags = 0; 3822 int num_flags = 0;
3784 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; 3823 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g';
3785 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; 3824 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
3786 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; 3825 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
3787 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf))); 3826 ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
3788 return FACTORY->LookupSymbol( 3827 return FACTORY->LookupSymbol(
3789 i::Vector<const char>(flags_buf, num_flags)); 3828 i::Vector<const char>(flags_buf, num_flags));
3790 } 3829 }
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
4967 5006
4968 5007
4969 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) { 5008 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) {
4970 IsDeadCheck("v8::HeapProfiler::FindSnapshot"); 5009 IsDeadCheck("v8::HeapProfiler::FindSnapshot");
4971 return reinterpret_cast<const HeapSnapshot*>( 5010 return reinterpret_cast<const HeapSnapshot*>(
4972 i::HeapProfiler::FindSnapshot(uid)); 5011 i::HeapProfiler::FindSnapshot(uid));
4973 } 5012 }
4974 5013
4975 5014
4976 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title, 5015 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
4977 HeapSnapshot::Type type) { 5016 HeapSnapshot::Type type,
5017 ActivityControl* control) {
4978 IsDeadCheck("v8::HeapProfiler::TakeSnapshot"); 5018 IsDeadCheck("v8::HeapProfiler::TakeSnapshot");
4979 i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull; 5019 i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull;
4980 switch (type) { 5020 switch (type) {
4981 case HeapSnapshot::kFull: 5021 case HeapSnapshot::kFull:
4982 internal_type = i::HeapSnapshot::kFull; 5022 internal_type = i::HeapSnapshot::kFull;
4983 break; 5023 break;
4984 case HeapSnapshot::kAggregated: 5024 case HeapSnapshot::kAggregated:
4985 internal_type = i::HeapSnapshot::kAggregated; 5025 internal_type = i::HeapSnapshot::kAggregated;
4986 break; 5026 break;
4987 default: 5027 default:
4988 UNREACHABLE(); 5028 UNREACHABLE();
4989 } 5029 }
4990 return reinterpret_cast<const HeapSnapshot*>( 5030 return reinterpret_cast<const HeapSnapshot*>(
4991 i::HeapProfiler::TakeSnapshot(*Utils::OpenHandle(*title), internal_type)); 5031 i::HeapProfiler::TakeSnapshot(
5032 *Utils::OpenHandle(*title), internal_type, control));
4992 } 5033 }
4993 5034
4994 #endif // ENABLE_LOGGING_AND_PROFILING 5035 #endif // ENABLE_LOGGING_AND_PROFILING
4995 5036
4996 5037
4997 v8::Testing::StressType internal::Testing::stress_type_ = 5038 v8::Testing::StressType internal::Testing::stress_type_ =
4998 v8::Testing::kStressTypeOpt; 5039 v8::Testing::kStressTypeOpt;
4999 5040
5000 5041
5001 void Testing::SetStressRunType(Testing::StressType type) { 5042 void Testing::SetStressRunType(Testing::StressType type) {
5002 internal::Testing::set_stress_type(type); 5043 internal::Testing::set_stress_type(type);
5003 } 5044 }
5004 5045
5005 int Testing::GetStressRuns() { 5046 int Testing::GetStressRuns() {
5047 if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs;
5006 #ifdef DEBUG 5048 #ifdef DEBUG
5007 // In debug mode the code runs much slower so stressing will only make two 5049 // In debug mode the code runs much slower so stressing will only make two
5008 // runs. 5050 // runs.
5009 return 2; 5051 return 2;
5010 #else 5052 #else
5011 return 5; 5053 return 5;
5012 #endif 5054 #endif
5013 } 5055 }
5014 5056
5015 5057
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
5116 5158
5117 5159
5118 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5160 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5119 HandleScopeImplementer* thread_local = 5161 HandleScopeImplementer* thread_local =
5120 reinterpret_cast<HandleScopeImplementer*>(storage); 5162 reinterpret_cast<HandleScopeImplementer*>(storage);
5121 thread_local->IterateThis(v); 5163 thread_local->IterateThis(v);
5122 return storage + ArchiveSpacePerThread(); 5164 return storage + ArchiveSpacePerThread();
5123 } 5165 }
5124 5166
5125 } } // namespace v8::internal 5167 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/allocation.h ('k') | src/arm/code-stubs-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698