Commit b8eb36a9 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Only to the relevant checks in LoadFunctionPrototype

BUG=
R=mvstanton@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22550 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 51ff0b5e
...@@ -2283,14 +2283,15 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -2283,14 +2283,15 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
Register scratch, Register scratch,
Label* miss, Label* miss,
bool miss_on_bound_function) { bool miss_on_bound_function) {
// Check that the receiver isn't a smi. Label non_instance;
JumpIfSmi(function, miss); if (miss_on_bound_function) {
// Check that the receiver isn't a smi.
JumpIfSmi(function, miss);
// Check that the function really is a function. Load map into result reg. // Check that the function really is a function. Load map into result reg.
CompareObjectType(function, result, scratch, JS_FUNCTION_TYPE); CompareObjectType(function, result, scratch, JS_FUNCTION_TYPE);
b(ne, miss); b(ne, miss);
if (miss_on_bound_function) {
ldr(scratch, ldr(scratch,
FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset)); FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset));
ldr(scratch, ldr(scratch,
...@@ -2298,13 +2299,12 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -2298,13 +2299,12 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
tst(scratch, tst(scratch,
Operand(Smi::FromInt(1 << SharedFunctionInfo::kBoundFunction))); Operand(Smi::FromInt(1 << SharedFunctionInfo::kBoundFunction)));
b(ne, miss); b(ne, miss);
}
// Make sure that the function has an instance prototype. // Make sure that the function has an instance prototype.
Label non_instance; ldrb(scratch, FieldMemOperand(result, Map::kBitFieldOffset));
ldrb(scratch, FieldMemOperand(result, Map::kBitFieldOffset)); tst(scratch, Operand(1 << Map::kHasNonInstancePrototype));
tst(scratch, Operand(1 << Map::kHasNonInstancePrototype)); b(ne, &non_instance);
b(ne, &non_instance); }
// Get the prototype or initial map from the function. // Get the prototype or initial map from the function.
ldr(result, ldr(result,
...@@ -2324,12 +2324,15 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -2324,12 +2324,15 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
// Get the prototype from the initial map. // Get the prototype from the initial map.
ldr(result, FieldMemOperand(result, Map::kPrototypeOffset)); ldr(result, FieldMemOperand(result, Map::kPrototypeOffset));
jmp(&done);
// Non-instance prototype: Fetch prototype from constructor field if (miss_on_bound_function) {
// in initial map. jmp(&done);
bind(&non_instance);
ldr(result, FieldMemOperand(result, Map::kConstructorOffset)); // Non-instance prototype: Fetch prototype from constructor field
// in initial map.
bind(&non_instance);
ldr(result, FieldMemOperand(result, Map::kConstructorOffset));
}
// All done. // All done.
bind(&done); bind(&done);
......
...@@ -3816,13 +3816,14 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -3816,13 +3816,14 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
BoundFunctionAction action) { BoundFunctionAction action) {
ASSERT(!AreAliased(function, result, scratch)); ASSERT(!AreAliased(function, result, scratch));
// Check that the receiver isn't a smi. Label non_instance;
JumpIfSmi(function, miss); if (action == kMissOnBoundFunction) {
// Check that the receiver isn't a smi.
JumpIfSmi(function, miss);
// Check that the function really is a function. Load map into result reg. // Check that the function really is a function. Load map into result reg.
JumpIfNotObjectType(function, result, scratch, JS_FUNCTION_TYPE, miss); JumpIfNotObjectType(function, result, scratch, JS_FUNCTION_TYPE, miss);
if (action == kMissOnBoundFunction) {
Register scratch_w = scratch.W(); Register scratch_w = scratch.W();
Ldr(scratch, Ldr(scratch,
FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset)); FieldMemOperand(function, JSFunction::kSharedFunctionInfoOffset));
...@@ -3831,12 +3832,11 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -3831,12 +3832,11 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
Ldr(scratch_w, Ldr(scratch_w,
FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset)); FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset));
Tbnz(scratch, SharedFunctionInfo::kBoundFunction, miss); Tbnz(scratch, SharedFunctionInfo::kBoundFunction, miss);
}
// Make sure that the function has an instance prototype. // Make sure that the function has an instance prototype.
Label non_instance; Ldrb(scratch, FieldMemOperand(result, Map::kBitFieldOffset));
Ldrb(scratch, FieldMemOperand(result, Map::kBitFieldOffset)); Tbnz(scratch, Map::kHasNonInstancePrototype, &non_instance);
Tbnz(scratch, Map::kHasNonInstancePrototype, &non_instance); }
// Get the prototype or initial map from the function. // Get the prototype or initial map from the function.
Ldr(result, Ldr(result,
...@@ -3853,12 +3853,15 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -3853,12 +3853,15 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
// Get the prototype from the initial map. // Get the prototype from the initial map.
Ldr(result, FieldMemOperand(result, Map::kPrototypeOffset)); Ldr(result, FieldMemOperand(result, Map::kPrototypeOffset));
B(&done);
// Non-instance prototype: fetch prototype from constructor field in initial if (action == kMissOnBoundFunction) {
// map. B(&done);
Bind(&non_instance);
Ldr(result, FieldMemOperand(result, Map::kConstructorOffset)); // Non-instance prototype: fetch prototype from constructor field in initial
// map.
Bind(&non_instance);
Ldr(result, FieldMemOperand(result, Map::kConstructorOffset));
}
// All done. // All done.
Bind(&done); Bind(&done);
......
...@@ -1976,27 +1976,27 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -1976,27 +1976,27 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
Register scratch, Register scratch,
Label* miss, Label* miss,
bool miss_on_bound_function) { bool miss_on_bound_function) {
// Check that the receiver isn't a smi. Label non_instance;
JumpIfSmi(function, miss); if (miss_on_bound_function) {
// Check that the receiver isn't a smi.
JumpIfSmi(function, miss);
// Check that the function really is a function. // Check that the function really is a function.
CmpObjectType(function, JS_FUNCTION_TYPE, result); CmpObjectType(function, JS_FUNCTION_TYPE, result);
j(not_equal, miss); j(not_equal, miss);
if (miss_on_bound_function) {
// If a bound function, go to miss label. // If a bound function, go to miss label.
mov(scratch, mov(scratch,
FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
BooleanBitTest(scratch, SharedFunctionInfo::kCompilerHintsOffset, BooleanBitTest(scratch, SharedFunctionInfo::kCompilerHintsOffset,
SharedFunctionInfo::kBoundFunction); SharedFunctionInfo::kBoundFunction);
j(not_zero, miss); j(not_zero, miss);
}
// Make sure that the function has an instance prototype. // Make sure that the function has an instance prototype.
Label non_instance; movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset));
movzx_b(scratch, FieldOperand(result, Map::kBitFieldOffset)); test(scratch, Immediate(1 << Map::kHasNonInstancePrototype));
test(scratch, Immediate(1 << Map::kHasNonInstancePrototype)); j(not_zero, &non_instance);
j(not_zero, &non_instance); }
// Get the prototype or initial map from the function. // Get the prototype or initial map from the function.
mov(result, mov(result,
...@@ -2015,12 +2015,15 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -2015,12 +2015,15 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
// Get the prototype from the initial map. // Get the prototype from the initial map.
mov(result, FieldOperand(result, Map::kPrototypeOffset)); mov(result, FieldOperand(result, Map::kPrototypeOffset));
jmp(&done);
// Non-instance prototype: Fetch prototype from constructor field if (miss_on_bound_function) {
// in initial map. jmp(&done);
bind(&non_instance);
mov(result, FieldOperand(result, Map::kConstructorOffset)); // Non-instance prototype: Fetch prototype from constructor field
// in initial map.
bind(&non_instance);
mov(result, FieldOperand(result, Map::kConstructorOffset));
}
// All done. // All done.
bind(&done); bind(&done);
......
...@@ -937,7 +937,8 @@ Handle<Code> LoadIC::CompileHandler(LookupResult* lookup, Handle<Object> object, ...@@ -937,7 +937,8 @@ Handle<Code> LoadIC::CompileHandler(LookupResult* lookup, Handle<Object> object,
// Use specialized code for getting prototype of functions. // Use specialized code for getting prototype of functions.
if (object->IsJSFunction() && if (object->IsJSFunction() &&
String::Equals(isolate()->factory()->prototype_string(), name) && String::Equals(isolate()->factory()->prototype_string(), name) &&
Handle<JSFunction>::cast(object)->should_have_prototype()) { Handle<JSFunction>::cast(object)->should_have_prototype() &&
!Handle<JSFunction>::cast(object)->map()->has_non_instance_prototype()) {
Handle<Code> stub; Handle<Code> stub;
FunctionPrototypeStub function_prototype_stub(isolate(), kind()); FunctionPrototypeStub function_prototype_stub(isolate(), kind());
return function_prototype_stub.GetCode(); return function_prototype_stub.GetCode();
......
...@@ -3745,15 +3745,16 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -3745,15 +3745,16 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
Register result, Register result,
Label* miss, Label* miss,
bool miss_on_bound_function) { bool miss_on_bound_function) {
// Check that the receiver isn't a smi. Label non_instance;
testl(function, Immediate(kSmiTagMask)); if (miss_on_bound_function) {
j(zero, miss); // Check that the receiver isn't a smi.
testl(function, Immediate(kSmiTagMask));
j(zero, miss);
// Check that the function really is a function. // Check that the function really is a function.
CmpObjectType(function, JS_FUNCTION_TYPE, result); CmpObjectType(function, JS_FUNCTION_TYPE, result);
j(not_equal, miss); j(not_equal, miss);
if (miss_on_bound_function) {
movp(kScratchRegister, movp(kScratchRegister,
FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
// It's not smi-tagged (stored in the top half of a smi-tagged 8-byte // It's not smi-tagged (stored in the top half of a smi-tagged 8-byte
...@@ -3762,13 +3763,12 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -3762,13 +3763,12 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
SharedFunctionInfo::kCompilerHintsOffset, SharedFunctionInfo::kCompilerHintsOffset,
SharedFunctionInfo::kBoundFunction); SharedFunctionInfo::kBoundFunction);
j(not_zero, miss); j(not_zero, miss);
}
// Make sure that the function has an instance prototype. // Make sure that the function has an instance prototype.
Label non_instance; testb(FieldOperand(result, Map::kBitFieldOffset),
testb(FieldOperand(result, Map::kBitFieldOffset), Immediate(1 << Map::kHasNonInstancePrototype));
Immediate(1 << Map::kHasNonInstancePrototype)); j(not_zero, &non_instance, Label::kNear);
j(not_zero, &non_instance, Label::kNear); }
// Get the prototype or initial map from the function. // Get the prototype or initial map from the function.
movp(result, movp(result,
...@@ -3787,12 +3787,15 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, ...@@ -3787,12 +3787,15 @@ void MacroAssembler::TryGetFunctionPrototype(Register function,
// Get the prototype from the initial map. // Get the prototype from the initial map.
movp(result, FieldOperand(result, Map::kPrototypeOffset)); movp(result, FieldOperand(result, Map::kPrototypeOffset));
jmp(&done, Label::kNear);
// Non-instance prototype: Fetch prototype from constructor field if (miss_on_bound_function) {
// in initial map. jmp(&done, Label::kNear);
bind(&non_instance);
movp(result, FieldOperand(result, Map::kConstructorOffset)); // Non-instance prototype: Fetch prototype from constructor field
// in initial map.
bind(&non_instance);
movp(result, FieldOperand(result, Map::kConstructorOffset));
}
// All done. // All done.
bind(&done); bind(&done);
......
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