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

Side by Side Diff: src/inspector/v8-console.cc

Issue 2505493002: [inspector] make console.assert much faster (Closed)
Patch Set: Created 4 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/isolate.cc » ('j') | test/inspector/console/console-assert.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/inspector/v8-console.h" 5 #include "src/inspector/v8-console.h"
6 6
7 #include "src/base/macros.h" 7 #include "src/base/macros.h"
8 #include "src/inspector/injected-script.h" 8 #include "src/inspector/injected-script.h"
9 #include "src/inspector/inspected-context.h" 9 #include "src/inspector/inspected-context.h"
10 #include "src/inspector/string-util.h" 10 #include "src/inspector/string-util.h"
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 V8Console::timelineCallback); 707 V8Console::timelineCallback);
708 createBoundFunctionProperty(context, console, "timelineEnd", 708 createBoundFunctionProperty(context, console, "timelineEnd",
709 V8Console::timelineEndCallback); 709 V8Console::timelineEndCallback);
710 createBoundFunctionProperty(context, console, "time", 710 createBoundFunctionProperty(context, console, "time",
711 V8Console::timeCallback); 711 V8Console::timeCallback);
712 createBoundFunctionProperty(context, console, "timeEnd", 712 createBoundFunctionProperty(context, console, "timeEnd",
713 V8Console::timeEndCallback); 713 V8Console::timeEndCallback);
714 createBoundFunctionProperty(context, console, "timeStamp", 714 createBoundFunctionProperty(context, console, "timeStamp",
715 V8Console::timeStampCallback); 715 V8Console::timeStampCallback);
716 716
717 const char* jsConsoleAssert =
718 "(function(){\n"
719 "var assert = this.assert;\n"
720 "this.assert = (value, ...args) => value ? undefined : assert(value, "
721 "...args);\n"
722 "})";
723 v8::Local<v8::String> jsConsoleAssertSource =
724 toV8StringInternalized(isolate, jsConsoleAssert);
725 V8InspectorImpl* inspector = inspectedContext->inspector();
726 v8::Local<v8::Value> consoleAssertValue;
727 if (inspector->compileAndRunInternalScript(context, jsConsoleAssertSource)
728 .ToLocal(&consoleAssertValue) &&
729 consoleAssertValue->IsFunction()) {
730 v8::Local<v8::Function> consoleAssert =
731 v8::Local<v8::Function>::Cast(consoleAssertValue);
732 inspector->callFunction(consoleAssert, context, console, 0, nullptr);
733 }
734
717 if (hasMemoryAttribute) 735 if (hasMemoryAttribute)
718 console->SetAccessorProperty( 736 console->SetAccessorProperty(
719 toV8StringInternalized(isolate, "memory"), 737 toV8StringInternalized(isolate, "memory"),
720 v8::Function::New(context, V8Console::memoryGetterCallback, console, 0, 738 v8::Function::New(context, V8Console::memoryGetterCallback, console, 0,
721 v8::ConstructorBehavior::kThrow) 739 v8::ConstructorBehavior::kThrow)
722 .ToLocalChecked(), 740 .ToLocalChecked(),
723 v8::Function::New(context, V8Console::memorySetterCallback, 741 v8::Function::New(context, V8Console::memorySetterCallback,
724 v8::Local<v8::Value>(), 0, 742 v8::Local<v8::Value>(), 0,
725 v8::ConstructorBehavior::kThrow) 743 v8::ConstructorBehavior::kThrow)
726 .ToLocalChecked(), 744 .ToLocalChecked(),
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 ->GetOwnPropertyDescriptor( 930 ->GetOwnPropertyDescriptor(
913 m_context, v8::Local<v8::String>::Cast(name)) 931 m_context, v8::Local<v8::String>::Cast(name))
914 .ToLocal(&descriptor); 932 .ToLocal(&descriptor);
915 DCHECK(success); 933 DCHECK(success);
916 USE(success); 934 USE(success);
917 } 935 }
918 } 936 }
919 } 937 }
920 938
921 } // namespace v8_inspector 939 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « no previous file | src/isolate.cc » ('j') | test/inspector/console/console-assert.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698