Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(843)

Side by Side Diff: test/cctest/test-func-name-inference.cc

Issue 16337005: Deprecate FACTORY helper macro. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-disasm-ia32.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 using ::v8::internal::Runtime; 44 using ::v8::internal::Runtime;
45 using ::v8::internal::Script; 45 using ::v8::internal::Script;
46 using ::v8::internal::SmartArrayPointer; 46 using ::v8::internal::SmartArrayPointer;
47 using ::v8::internal::SharedFunctionInfo; 47 using ::v8::internal::SharedFunctionInfo;
48 using ::v8::internal::String; 48 using ::v8::internal::String;
49 49
50 50
51 static void CheckFunctionName(v8::Handle<v8::Script> script, 51 static void CheckFunctionName(v8::Handle<v8::Script> script,
52 const char* func_pos_src, 52 const char* func_pos_src,
53 const char* ref_inferred_name) { 53 const char* ref_inferred_name) {
54 Isolate* isolate = Isolate::Current();
55 Factory* factory = isolate->factory();
56
54 // Get script source. 57 // Get script source.
55 Handle<Object> obj = v8::Utils::OpenHandle(*script); 58 Handle<Object> obj = v8::Utils::OpenHandle(*script);
56 Handle<SharedFunctionInfo> shared_function; 59 Handle<SharedFunctionInfo> shared_function;
57 if (obj->IsSharedFunctionInfo()) { 60 if (obj->IsSharedFunctionInfo()) {
58 shared_function = 61 shared_function =
59 Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(*obj)); 62 Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(*obj));
60 } else { 63 } else {
61 shared_function = 64 shared_function =
62 Handle<SharedFunctionInfo>(JSFunction::cast(*obj)->shared()); 65 Handle<SharedFunctionInfo>(JSFunction::cast(*obj)->shared());
63 } 66 }
64 Handle<Script> i_script(Script::cast(shared_function->script())); 67 Handle<Script> i_script(Script::cast(shared_function->script()));
65 CHECK(i_script->source()->IsString()); 68 CHECK(i_script->source()->IsString());
66 Handle<String> script_src(String::cast(i_script->source())); 69 Handle<String> script_src(String::cast(i_script->source()));
67 70
68 // Find the position of a given func source substring in the source. 71 // Find the position of a given func source substring in the source.
69 Handle<String> func_pos_str = 72 Handle<String> func_pos_str =
70 FACTORY->NewStringFromAscii(CStrVector(func_pos_src)); 73 factory->NewStringFromAscii(CStrVector(func_pos_src));
71 int func_pos = Runtime::StringMatch(Isolate::Current(), 74 int func_pos = Runtime::StringMatch(isolate,
72 script_src, 75 script_src,
73 func_pos_str, 76 func_pos_str,
74 0); 77 0);
75 CHECK_NE(0, func_pos); 78 CHECK_NE(0, func_pos);
76 79
77 #ifdef ENABLE_DEBUGGER_SUPPORT 80 #ifdef ENABLE_DEBUGGER_SUPPORT
78 // Obtain SharedFunctionInfo for the function. 81 // Obtain SharedFunctionInfo for the function.
79 Isolate::Current()->debug()->PrepareForBreakPoints(); 82 isolate->debug()->PrepareForBreakPoints();
80 Object* shared_func_info_ptr = 83 Object* shared_func_info_ptr =
81 Isolate::Current()->debug()->FindSharedFunctionInfoInScript(i_script, 84 isolate->debug()->FindSharedFunctionInfoInScript(i_script, func_pos);
82 func_pos);
83 CHECK(shared_func_info_ptr != HEAP->undefined_value()); 85 CHECK(shared_func_info_ptr != HEAP->undefined_value());
84 Handle<SharedFunctionInfo> shared_func_info( 86 Handle<SharedFunctionInfo> shared_func_info(
85 SharedFunctionInfo::cast(shared_func_info_ptr)); 87 SharedFunctionInfo::cast(shared_func_info_ptr));
86 88
87 // Verify inferred function name. 89 // Verify inferred function name.
88 SmartArrayPointer<char> inferred_name = 90 SmartArrayPointer<char> inferred_name =
89 shared_func_info->inferred_name()->ToCString(); 91 shared_func_info->inferred_name()->ToCString();
90 CHECK_EQ(ref_inferred_name, *inferred_name); 92 CHECK_EQ(ref_inferred_name, *inferred_name);
91 #endif // ENABLE_DEBUGGER_SUPPORT 93 #endif // ENABLE_DEBUGGER_SUPPORT
92 } 94 }
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 " };\n" 475 " };\n"
474 " var foo = 10;\n" 476 " var foo = 10;\n"
475 " function f() {\n" 477 " function f() {\n"
476 " return wrapCode();\n" 478 " return wrapCode();\n"
477 " }\n" 479 " }\n"
478 " this.ref = f;\n" 480 " this.ref = f;\n"
479 "})()"); 481 "})()");
480 script->Run(); 482 script->Run();
481 CheckFunctionName(script, "return 2012", ""); 483 CheckFunctionName(script, "return 2012", "");
482 } 484 }
OLDNEW
« no previous file with comments | « test/cctest/test-disasm-ia32.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698