• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/extensions/trigger-failure-extension.h"
6 
7 #include "src/base/logging.h"
8 #include "src/checks.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 
14 const char* const TriggerFailureExtension::kSource =
15     "native function triggerCheckFalse();"
16     "native function triggerAssertFalse();"
17     "native function triggerSlowAssertFalse();";
18 
19 
20 v8::Local<v8::FunctionTemplate>
GetNativeFunctionTemplate(v8::Isolate * isolate,v8::Local<v8::String> str)21 TriggerFailureExtension::GetNativeFunctionTemplate(v8::Isolate* isolate,
22                                                    v8::Local<v8::String> str) {
23   if (strcmp(*v8::String::Utf8Value(isolate, str), "triggerCheckFalse") == 0) {
24     return v8::FunctionTemplate::New(
25         isolate,
26         TriggerFailureExtension::TriggerCheckFalse);
27   } else if (strcmp(*v8::String::Utf8Value(isolate, str),
28                     "triggerAssertFalse") == 0) {
29     return v8::FunctionTemplate::New(
30         isolate,
31         TriggerFailureExtension::TriggerAssertFalse);
32   } else {
33     CHECK_EQ(0, strcmp(*v8::String::Utf8Value(isolate, str),
34                        "triggerSlowAssertFalse"));
35     return v8::FunctionTemplate::New(
36         isolate,
37         TriggerFailureExtension::TriggerSlowAssertFalse);
38   }
39 }
40 
41 
TriggerCheckFalse(const v8::FunctionCallbackInfo<v8::Value> & args)42 void TriggerFailureExtension::TriggerCheckFalse(
43     const v8::FunctionCallbackInfo<v8::Value>& args) {
44   CHECK(false);
45 }
46 
47 
TriggerAssertFalse(const v8::FunctionCallbackInfo<v8::Value> & args)48 void TriggerFailureExtension::TriggerAssertFalse(
49     const v8::FunctionCallbackInfo<v8::Value>& args) {
50   DCHECK(false);
51 }
52 
53 
TriggerSlowAssertFalse(const v8::FunctionCallbackInfo<v8::Value> & args)54 void TriggerFailureExtension::TriggerSlowAssertFalse(
55     const v8::FunctionCallbackInfo<v8::Value>& args) {
56   SLOW_DCHECK(false);
57 }
58 
59 }  // namespace internal
60 }  // namespace v8
61