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 #include "src/v8.h" 7 8 namespace v8 { 9 namespace internal { 10 11 12 const char* const TriggerFailureExtension::kSource = 13 "native function triggerCheckFalse();" 14 "native function triggerAssertFalse();" 15 "native function triggerSlowAssertFalse();"; 16 17 18 v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(v8::Isolate * isolate,v8::Handle<v8::String> str)19TriggerFailureExtension::GetNativeFunctionTemplate( 20 v8::Isolate* isolate, 21 v8::Handle<v8::String> str) { 22 if (strcmp(*v8::String::Utf8Value(str), "triggerCheckFalse") == 0) { 23 return v8::FunctionTemplate::New( 24 isolate, 25 TriggerFailureExtension::TriggerCheckFalse); 26 } else if (strcmp(*v8::String::Utf8Value(str), "triggerAssertFalse") == 0) { 27 return v8::FunctionTemplate::New( 28 isolate, 29 TriggerFailureExtension::TriggerAssertFalse); 30 } else { 31 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(str), "triggerSlowAssertFalse")); 32 return v8::FunctionTemplate::New( 33 isolate, 34 TriggerFailureExtension::TriggerSlowAssertFalse); 35 } 36 } 37 38 TriggerCheckFalse(const v8::FunctionCallbackInfo<v8::Value> & args)39void TriggerFailureExtension::TriggerCheckFalse( 40 const v8::FunctionCallbackInfo<v8::Value>& args) { 41 CHECK(false); 42 } 43 44 TriggerAssertFalse(const v8::FunctionCallbackInfo<v8::Value> & args)45void TriggerFailureExtension::TriggerAssertFalse( 46 const v8::FunctionCallbackInfo<v8::Value>& args) { 47 ASSERT(false); 48 } 49 50 TriggerSlowAssertFalse(const v8::FunctionCallbackInfo<v8::Value> & args)51void TriggerFailureExtension::TriggerSlowAssertFalse( 52 const v8::FunctionCallbackInfo<v8::Value>& args) { 53 SLOW_ASSERT(false); 54 } 55 56 } } // namespace v8::internal 57