void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
Comment cmnt(masm_, "[ FunctionLiteral");
- // Build the function boilerplate and instantiate it.
+ // Build the shared function info and instantiate the function based
+ // on it.
Handle<SharedFunctionInfo> function_info =
Compiler::BuildFunctionInfo(expr, script(), this);
if (HasStackOverflow()) return;
if (probe->IsSharedFunctionInfo()) {
Handle<SharedFunctionInfo> function_info =
Handle<SharedFunctionInfo>::cast(probe);
- // Break when we've found a suitable boilerplate function that
+ // Break when we've found a suitable shared function info that
// matches the origin.
if (HasOrigin(function_info, name, line_offset, column_offset)) {
result = *function_info;
namespace internal {
-// The compilation cache keeps function boilerplates for compiled
-// scripts and evals. The boilerplates are looked up using the source
-// string as the key. For regular expressions the compilation data is cached.
+// The compilation cache keeps shared function infos for compiled
+// scripts and evals. The shared function infos are looked up using
+// the source string as the key. For regular expressions the
+// compilation data is cached.
class CompilationCache {
public:
- // Finds the script function boilerplate for a source
+ // Finds the script shared function info for a source
// string. Returns an empty handle if the cache doesn't contain a
// script for the given source string with the right origin.
static Handle<SharedFunctionInfo> LookupScript(Handle<String> source,
int line_offset,
int column_offset);
- // Finds the function boilerplate for a source string for eval in a
+ // Finds the shared function info for a source string for eval in a
// given context. Returns an empty handle if the cache doesn't
// contain a script for the given source string.
static Handle<SharedFunctionInfo> LookupEval(Handle<String> source,
static Handle<FixedArray> LookupRegExp(Handle<String> source,
JSRegExp::Flags flags);
- // Associate the (source, kind) pair to the boilerplate. This may
- // overwrite an existing mapping.
+ // Associate the (source, kind) pair to the shared function
+ // info. This may overwrite an existing mapping.
static void PutScript(Handle<String> source,
Handle<SharedFunctionInfo> function_info);
// Associate the (source, context->closure()->shared(), kind) triple
- // with the boilerplate. This may overwrite an existing mapping.
+ // with the shared function info. This may overwrite an existing mapping.
static void PutEval(Handle<String> source,
Handle<Context> context,
bool is_global,
code);
}
- // Create a boilerplate function.
+ // Create a shared function info object.
Handle<SharedFunctionInfo> result =
Factory::NewSharedFunctionInfo(literal->name(),
literal->materialized_literal_count(),
int argc,
Object*** args,
bool* has_pending_exception) {
- // Make sure we have a real function, not a boilerplate function.
- ASSERT(!func->IsBoilerplate());
-
// Entering JavaScript.
VMState state(JS);
context->global_context());
}
result->set_literals(*literals);
- ASSERT(!result->IsBoilerplate());
return result;
}
if (obj->IsFailure()) return false;
set_global_context_map(Map::cast(obj));
- obj = AllocateMap(JS_FUNCTION_TYPE, JSFunction::kSize);
- if (obj->IsFailure()) return false;
- set_boilerplate_function_map(Map::cast(obj));
-
obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE,
SharedFunctionInfo::kAlignedSize);
if (obj->IsFailure()) return false;
V(Map, code_map, CodeMap) \
V(Map, oddball_map, OddballMap) \
V(Map, global_property_cell_map, GlobalPropertyCellMap) \
- V(Map, boilerplate_function_map, BoilerplateFunctionMap) \
V(Map, shared_function_info_map, SharedFunctionInfoMap) \
V(Map, proxy_map, ProxyMap) \
V(Object, nan_value, NanValue) \
frame()->EmitPush(Immediate(function_info));
return frame()->CallStub(&stub, 1);
} else {
- // Call the runtime to instantiate the function boilerplate
- // object.
+ // Call the runtime to instantiate the function based on the
+ // shared function info.
frame()->EmitPush(esi);
frame()->EmitPush(Immediate(function_info));
return frame()->CallRuntime(Runtime::kNewClosure, 2);
void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
Comment cmnt(masm_, "[ FunctionLiteral");
- // Build the function boilerplate and instantiate it.
+ // Build the shared function info and instantiate the function based
+ // on it.
Handle<SharedFunctionInfo> function_info =
Compiler::BuildFunctionInfo(expr, script(), this);
if (HasStackOverflow()) return;
void JSFunction::JSFunctionPrint() {
HeapObject::PrintHeader("Function");
PrintF(" - map = 0x%p\n", map());
- PrintF(" - is boilerplate: %s\n", IsBoilerplate() ? "yes" : "no");
PrintF(" - initial_map = ");
if (has_initial_map()) {
initial_map()->ShortPrint();
}
-bool JSFunction::IsBoilerplate() {
- return map() == Heap::boilerplate_function_map();
-}
-
-
bool JSFunction::IsBuiltin() {
return context()->global()->IsJSBuiltinsObject();
}
int JSFunction::NumberOfLiterals() {
- ASSERT(!IsBoilerplate());
return literals()->length();
}
String* JSObject::constructor_name() {
if (IsJSFunction()) {
- return JSFunction::cast(this)->IsBoilerplate() ?
- Heap::function_class_symbol() : Heap::closure_symbol();
+ return Heap::closure_symbol();
}
if (map()->constructor()->IsJSFunction()) {
JSFunction* constructor = JSFunction::cast(map()->constructor());
break;
}
- // For functions check the context. Boilerplate functions do
- // not have to be traversed since they have no real context.
- if (IsJSFunction() && !JSFunction::cast(this)->IsBoilerplate()) {
+ // For functions check the context.
+ if (IsJSFunction()) {
// Get the constructor function for arguments array.
JSObject* arguments_boilerplate =
Top::context()->global_context()->arguments_boilerplate();
inline Code* code();
inline void set_code(Code* value);
- // Tells whether this function is a context-independent boilerplate
- // function.
- inline bool IsBoilerplate();
-
// Tells whether this function is builtin.
inline bool IsBuiltin();
extension_->GetNativeFunction(v8::Utils::ToLocal(name));
ASSERT(!fun_template.IsEmpty());
- // Instantiate the function and create a boilerplate function from it.
+ // Instantiate the function and create a shared function info from it.
Handle<JSFunction> fun = Utils::OpenHandle(*fun_template->GetFunction());
const int literals = fun->NumberOfLiterals();
Handle<Code> code = Handle<Code>(fun->shared()->code());
Factory::NewSharedFunctionInfo(name, literals, code);
shared->set_construct_stub(*construct_stub);
- // Copy the function data to the boilerplate.
+ // Copy the function data to the shared function info.
shared->set_function_data(fun->shared()->function_data());
int parameters = fun->shared()->formal_parameter_count();
shared->set_formal_parameter_count(parameters);
Result answer = frame_->CallStub(&stub, 1);
frame_->Push(&answer);
} else {
- // Call the runtime to instantiate the function boilerplate
- // object.
+ // Call the runtime to instantiate the function based on the
+ // shared function info.
frame_->EmitPush(rsi);
frame_->EmitPush(function_info);
Result result = frame_->CallRuntime(Runtime::kNewClosure, 2);
void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
Comment cmnt(masm_, "[ FunctionLiteral");
- // Build the function boilerplate and instantiate it.
+ // Build the shared function info and instantiate the function based
+ // on it.
Handle<SharedFunctionInfo> function_info =
Compiler::BuildFunctionInfo(expr, script(), this);
if (HasStackOverflow()) return;