Commit 2bcbd1e8 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[V8] Add FunctionMirror.prototype.contextDebugId method

This method returns contextDebugId for function. We can't use context_data from FunctionMirror.prototype.script because it can be incorrect when compilation cache is used and one script object was used for JSFunctions in different contexts.

BUG=chromium:595206
LOG=Y
R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/1840713002

Cr-Commit-Position: refs/heads/master@{#35117}
parent 229cc17f
......@@ -1037,6 +1037,15 @@ FunctionMirror.prototype.toText = function() {
};
FunctionMirror.prototype.context = function() {
if (this.resolved()) {
if (!this._context)
this._context = new ContextMirror(%FunctionGetContextData(this.value_));
return this._context;
}
};
/**
* Mirror object for unresolved functions.
* @param {string} value The name for the unresolved function reflected by this
......
......@@ -96,6 +96,14 @@ RUNTIME_FUNCTION(Runtime_FunctionGetPositionForOffset) {
return Smi::FromInt(abstract_code->SourcePosition(offset));
}
RUNTIME_FUNCTION(Runtime_FunctionGetContextData) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_CHECKED(JSFunction, fun, 0);
FixedArray* array = fun->native_context()->embedder_data();
return array->get(v8::Context::kDebugIdIndex);
}
RUNTIME_FUNCTION(Runtime_FunctionSetInstanceClassName) {
SealHandleScope shs(isolate);
......
......@@ -218,6 +218,7 @@ namespace internal {
F(FunctionGetSourceCode, 1, 1) \
F(FunctionGetScriptSourcePosition, 1, 1) \
F(FunctionGetPositionForOffset, 2, 1) \
F(FunctionGetContextData, 1, 1) \
F(FunctionSetInstanceClassName, 2, 1) \
F(FunctionSetLength, 2, 1) \
F(FunctionSetPrototype, 2, 1) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment