api-arguments.cc 1.72 KB
Newer Older
1 2 3 4 5 6
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/api-arguments.h"

7
#include "src/debug/debug.h"
8
#include "src/objects-inl.h"
9 10 11
#include "src/tracing/trace-event.h"
#include "src/vm-state-inl.h"

12 13 14
namespace v8 {
namespace internal {

15
Handle<Object> FunctionCallbackArguments::Call(FunctionCallback f) {
16
  Isolate* isolate = this->isolate();
17 18 19 20
  if (isolate->needs_side_effect_check() &&
      !isolate->debug()->PerformSideEffectCheckForCallback(FUNCTION_ADDR(f))) {
    return Handle<Object>();
  }
21
  RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::FunctionCallback);
22 23
  VMState<EXTERNAL> state(isolate);
  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
24
  FunctionCallbackInfo<v8::Value> info(begin(), argv_, argc_);
25
  f(info);
26
  return GetReturnValue<Object>(isolate);
27 28
}

29 30 31
Handle<JSObject> PropertyCallbackArguments::Call(
    IndexedPropertyEnumeratorCallback f) {
  Isolate* isolate = this->isolate();
32 33 34 35
  if (isolate->needs_side_effect_check() &&
      !isolate->debug()->PerformSideEffectCheckForCallback(FUNCTION_ADDR(f))) {
    return Handle<JSObject>();
  }
36
  RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::PropertyCallback);
37 38 39 40 41 42
  VMState<EXTERNAL> state(isolate);
  ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
  PropertyCallbackInfo<v8::Array> info(begin());
  f(info);
  return GetReturnValue<JSObject>(isolate);
}
43

44 45 46 47 48
bool PropertyCallbackArguments::PerformSideEffectCheck(Isolate* isolate,
                                                       Address function) {
  return isolate->debug()->PerformSideEffectCheckForCallback(function);
}

49 50
}  // namespace internal
}  // namespace v8