@@ -315,14 +315,11 @@ Object* Accessors::ScriptGetLineEnds(Object* object, void*) {
315315 HandleScope scope;
316316 Handle<Script> script (Script::cast (JSValue::cast (object)->value ()));
317317 InitScriptLineEnds (script);
318- if (script->line_ends_js_array ()->IsUndefined ()) {
319- Handle<FixedArray> line_ends_fixed_array (
320- FixedArray::cast (script->line_ends_fixed_array ()));
321- Handle<FixedArray> copy = Factory::CopyFixedArray (line_ends_fixed_array);
322- Handle<JSArray> js_array = Factory::NewJSArrayWithElements (copy);
323- script->set_line_ends_js_array (*js_array);
324- }
325- return script->line_ends_js_array ();
318+ ASSERT (script->line_ends ()->IsFixedArray ());
319+ Handle<FixedArray> line_ends (FixedArray::cast (script->line_ends ()));
320+ Handle<FixedArray> copy = Factory::CopyFixedArray (line_ends);
321+ Handle<JSArray> js_array = Factory::NewJSArrayWithElements (copy);
322+ return *js_array;
326323}
327324
328325
@@ -352,29 +349,38 @@ const AccessorDescriptor Accessors::ScriptContextData = {
352349
353350
354351//
355- // Accessors::ScriptGetEvalFromFunction
352+ // Accessors::ScriptGetEvalFromScript
356353//
357354
358355
359- Object* Accessors::ScriptGetEvalFromFunction (Object* object, void *) {
356+ Object* Accessors::ScriptGetEvalFromScript (Object* object, void *) {
360357 Object* script = JSValue::cast (object)->value ();
361- return Script::cast (script)->eval_from_function ();
358+ if (!Script::cast (script)->eval_from_shared ()->IsUndefined ()) {
359+ Handle<SharedFunctionInfo> eval_from_shared (
360+ SharedFunctionInfo::cast (Script::cast (script)->eval_from_shared ()));
361+
362+ if (eval_from_shared->script ()->IsScript ()) {
363+ Handle<Script> eval_from_script (Script::cast (eval_from_shared->script ()));
364+ return *GetScriptWrapper (eval_from_script);
365+ }
366+ }
367+ return Heap::undefined_value ();
362368}
363369
364370
365- const AccessorDescriptor Accessors::ScriptEvalFromFunction = {
366- ScriptGetEvalFromFunction ,
371+ const AccessorDescriptor Accessors::ScriptEvalFromScript = {
372+ ScriptGetEvalFromScript ,
367373 IllegalSetter,
368374 0
369375};
370376
371377
372378//
373- // Accessors::ScriptGetEvalFromPosition
379+ // Accessors::ScriptGetEvalFromScriptPosition
374380//
375381
376382
377- Object* Accessors::ScriptGetEvalFromPosition (Object* object, void *) {
383+ Object* Accessors::ScriptGetEvalFromScriptPosition (Object* object, void *) {
378384 HandleScope scope;
379385 Handle<Script> script (Script::cast (JSValue::cast (object)->value ()));
380386
@@ -386,14 +392,42 @@ Object* Accessors::ScriptGetEvalFromPosition(Object* object, void*) {
386392
387393 // Get the function from where eval was called and find the source position
388394 // from the instruction offset.
389- Handle<Code> code (JSFunction::cast (script->eval_from_function ())->code ());
395+ Handle<Code> code (SharedFunctionInfo::cast (
396+ script->eval_from_shared ())->code ());
390397 return Smi::FromInt (code->SourcePosition (code->instruction_start () +
391398 script->eval_from_instructions_offset ()->value ()));
392399}
393400
394401
395- const AccessorDescriptor Accessors::ScriptEvalFromPosition = {
396- ScriptGetEvalFromPosition,
402+ const AccessorDescriptor Accessors::ScriptEvalFromScriptPosition = {
403+ ScriptGetEvalFromScriptPosition,
404+ IllegalSetter,
405+ 0
406+ };
407+
408+
409+ //
410+ // Accessors::ScriptGetEvalFromFunctionName
411+ //
412+
413+
414+ Object* Accessors::ScriptGetEvalFromFunctionName (Object* object, void *) {
415+ Object* script = JSValue::cast (object)->value ();
416+ Handle<SharedFunctionInfo> shared (SharedFunctionInfo::cast (
417+ Script::cast (script)->eval_from_shared ()));
418+
419+
420+ // Find the name of the function calling eval.
421+ if (!shared->name ()->IsUndefined ()) {
422+ return shared->name ();
423+ } else {
424+ return shared->inferred_name ();
425+ }
426+ }
427+
428+
429+ const AccessorDescriptor Accessors::ScriptEvalFromFunctionName = {
430+ ScriptGetEvalFromFunctionName,
397431 IllegalSetter,
398432 0
399433};
0 commit comments