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

Side by Side Diff: src/bootstrapper.cc

Issue 1413503007: Provide a counter for thrown JavaScript errors per context (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Adapted to Yang's feedback Created 5 years, 1 month 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
« no previous file with comments | « no previous file | src/contexts.h » ('j') | src/contexts.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { 363 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
364 // object.__proto__ = proto; 364 // object.__proto__ = proto;
365 Handle<Map> old_map = Handle<Map>(object->map()); 365 Handle<Map> old_map = Handle<Map>(object->map());
366 Handle<Map> new_map = Map::Copy(old_map, "SetObjectPrototype"); 366 Handle<Map> new_map = Map::Copy(old_map, "SetObjectPrototype");
367 Map::SetPrototype(new_map, proto, FAST_PROTOTYPE); 367 Map::SetPrototype(new_map, proto, FAST_PROTOTYPE);
368 JSObject::MigrateToMap(object, new_map); 368 JSObject::MigrateToMap(object, new_map);
369 } 369 }
370 370
371 371
372 void Bootstrapper::DetachGlobal(Handle<Context> env) { 372 void Bootstrapper::DetachGlobal(Handle<Context> env) {
373 env->GetIsolate()->counters()->errors_thrown_per_context()->AddSample(
374 env->GetErrorsThrown());
375
373 Factory* factory = env->GetIsolate()->factory(); 376 Factory* factory = env->GetIsolate()->factory();
374 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); 377 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy()));
375 global_proxy->set_native_context(*factory->null_value()); 378 global_proxy->set_native_context(*factory->null_value());
376 SetObjectPrototype(global_proxy, factory->null_value()); 379 SetObjectPrototype(global_proxy, factory->null_value());
377 global_proxy->map()->SetConstructor(*factory->null_value()); 380 global_proxy->map()->SetConstructor(*factory->null_value());
378 if (FLAG_track_detached_contexts) { 381 if (FLAG_track_detached_contexts) {
379 env->GetIsolate()->AddDetachedContext(env); 382 env->GetIsolate()->AddDetachedContext(env);
380 } 383 }
381 } 384 }
382 385
(...skipping 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after
3144 !Snapshot::NewContextFromSnapshot(isolate, global_proxy, 3147 !Snapshot::NewContextFromSnapshot(isolate, global_proxy,
3145 &outdated_contexts) 3148 &outdated_contexts)
3146 .ToHandle(&native_context_)) { 3149 .ToHandle(&native_context_)) {
3147 native_context_ = Handle<Context>(); 3150 native_context_ = Handle<Context>();
3148 } 3151 }
3149 3152
3150 if (!native_context().is_null()) { 3153 if (!native_context().is_null()) {
3151 AddToWeakNativeContextList(*native_context()); 3154 AddToWeakNativeContextList(*native_context());
3152 isolate->set_context(*native_context()); 3155 isolate->set_context(*native_context());
3153 isolate->counters()->contexts_created_by_snapshot()->Increment(); 3156 isolate->counters()->contexts_created_by_snapshot()->Increment();
3157
3158 // Re-initialize the counter because it got incremented during snapshot
3159 // creation.
3160 isolate->native_context()->set_errors_thrown(Smi::FromInt(0));
Yang 2015/11/05 07:50:01 Move this below please. Otherwise we would get wro
Michael Hablich 2015/11/05 13:23:11 After an offline discussion I now get it why it sh
3161
3154 #if TRACE_MAPS 3162 #if TRACE_MAPS
3155 if (FLAG_trace_maps) { 3163 if (FLAG_trace_maps) {
3156 Handle<JSFunction> object_fun = isolate->object_function(); 3164 Handle<JSFunction> object_fun = isolate->object_function();
3157 PrintF("[TraceMap: InitialMap map= %p SFI= %d_Object ]\n", 3165 PrintF("[TraceMap: InitialMap map= %p SFI= %d_Object ]\n",
3158 reinterpret_cast<void*>(object_fun->initial_map()), 3166 reinterpret_cast<void*>(object_fun->initial_map()),
3159 object_fun->shared()->unique_id()); 3167 object_fun->shared()->unique_id());
3160 Map::TraceAllTransitions(object_fun->initial_map()); 3168 Map::TraceAllTransitions(object_fun->initial_map());
3161 } 3169 }
3162 #endif 3170 #endif
3163 Handle<JSGlobalObject> global_object = 3171 Handle<JSGlobalObject> global_object =
(...skipping 18 matching lines...) Expand all
3182 InitializeNormalizedMapCaches(); 3190 InitializeNormalizedMapCaches();
3183 3191
3184 if (!InstallNatives(context_type)) return; 3192 if (!InstallNatives(context_type)) return;
3185 3193
3186 MakeFunctionInstancePrototypeWritable(); 3194 MakeFunctionInstancePrototypeWritable();
3187 3195
3188 if (context_type != THIN_CONTEXT) { 3196 if (context_type != THIN_CONTEXT) {
3189 if (!InstallExtraNatives()) return; 3197 if (!InstallExtraNatives()) return;
3190 if (!ConfigureGlobalObjects(global_proxy_template)) return; 3198 if (!ConfigureGlobalObjects(global_proxy_template)) return;
3191 } 3199 }
3192 isolate->counters()->contexts_created_from_scratch()->Increment(); 3200 isolate->counters()->contexts_created_from_scratch()->Increment();
Yang 2015/11/05 07:50:01 Reinitalize counter here.
Michael Hablich 2015/11/05 13:23:11 Done.
3193 } 3201 }
3194 3202
3195 // Install experimental natives. Do not include them into the 3203 // Install experimental natives. Do not include them into the
3196 // snapshot as we should be able to turn them off at runtime. Re-installing 3204 // snapshot as we should be able to turn them off at runtime. Re-installing
3197 // them after they have already been deserialized would also fail. 3205 // them after they have already been deserialized would also fail.
3198 if (context_type == FULL_CONTEXT) { 3206 if (context_type == FULL_CONTEXT) {
3199 if (!isolate->serializer_enabled()) { 3207 if (!isolate->serializer_enabled()) {
3200 InitializeExperimentalGlobal(); 3208 InitializeExperimentalGlobal();
3201 if (!InstallExperimentalNatives()) return; 3209 if (!InstallExperimentalNatives()) return;
3202 3210
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3247 } 3255 }
3248 3256
3249 3257
3250 // Called when the top-level V8 mutex is destroyed. 3258 // Called when the top-level V8 mutex is destroyed.
3251 void Bootstrapper::FreeThreadResources() { 3259 void Bootstrapper::FreeThreadResources() {
3252 DCHECK(!IsActive()); 3260 DCHECK(!IsActive());
3253 } 3261 }
3254 3262
3255 } // namespace internal 3263 } // namespace internal
3256 } // namespace v8 3264 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/contexts.h » ('j') | src/contexts.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698