ObjFW  Check-in [f5747ff94a]

Overview
Comment:Better way of calling the forwarding handler.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | runtime
Files: files | file ages | folders
SHA3-256: f5747ff94afb6f3d972edd77cbb162860f616178e8a3f27203c9f26dcf3ddc4f
User & Date: js on 2012-05-09 13:54:48
Other Links: branch diff | manifest | tags
Context
2012-05-09
13:55
Initialize classes on the first dispatch. check-in: dcf845546a user: js tags: runtime
13:54
Better way of calling the forwarding handler. check-in: f5747ff94a user: js tags: runtime
2012-05-08
20:30
Add support for 16 bit selector UIDs. check-in: fef47937e5 user: js tags: runtime
Changes

Modified src/runtime/lookup-amd64-elf.S from [09c8f5af4a] to [2e8002927c].

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

	testq	%rax, %rax
	jz	forward

	ret

forward:
	mov	objc_forward_handler@GOTPCREL(%rip), %rax
	jmp	*(%rax)

objc_msg_lookup_super:
	movq	(%rdi), %rax
	testq	%rax, %rax
	jz	ret_nil








|







41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

	testq	%rax, %rax
	jz	forward

	ret

forward:
	mov	objc_not_found_handler@GOTPCREL(%rip), %rax
	jmp	*(%rax)

objc_msg_lookup_super:
	movq	(%rdi), %rax
	testq	%rax, %rax
	jz	ret_nil

Modified src/runtime/lookup-x86-elf.S from [d301a0d068] to [b73cd77fba].

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
	jz	forward

	ret

forward:
	call	get_eip
.L1:
	addl	$objc_forward_handler-.L1, %eax
	jmp	*(%eax)

objc_msg_lookup_super:
	movl	4(%esp), %edx
	cmpl	$0, (%edx)
	je	ret_nil








|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
	jz	forward

	ret

forward:
	call	get_eip
.L1:
	addl	$objc_not_found_handler-.L1, %eax
	jmp	*(%eax)

objc_msg_lookup_super:
	movl	4(%esp), %edx
	cmpl	$0, (%edx)
	je	ret_nil

Modified src/runtime/lookup.m from [4a37e847d8] to [9ff82b2e4e].

19
20
21
22
23
24
25
26
27
28
29
30
31



32
33
34
35
36
37
38
#include <stdio.h>
#include <stdlib.h>

#import "runtime.h"
#import "runtime-private.h"
#import "macros.h"

static IMP not_found_handler(id, SEL);
IMP (*objc_forward_handler)(id, SEL) = not_found_handler;

static IMP
not_found_handler(id obj, SEL sel)
{



	ERROR("Selector %s is not implemented for class %s!",
	    sel_getName(sel), obj->isa->name);
}

BOOL
class_respondsToSelector(Class cls, SEL sel)
{







<
|

|
|

>
>
>







19
20
21
22
23
24
25

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <stdlib.h>

#import "runtime.h"
#import "runtime-private.h"
#import "macros.h"


IMP (*objc_forward_handler)(id, SEL) = NULL;

IMP
objc_not_found_handler(id obj, SEL sel)
{
	if (objc_forward_handler != NULL)
		return objc_forward_handler(obj, sel);

	ERROR("Selector %s is not implemented for class %s!",
	    sel_getName(sel), obj->isa->name);
}

BOOL
class_respondsToSelector(Class cls, SEL sel)
{
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

	if (obj == nil)
		return (IMP)nil_method;

	imp = objc_sparsearray_get(obj->isa->dtable, (uint32_t)sel->uid);

	if (imp == NULL)
		return objc_forward_handler(obj, sel);

	return imp;
}

IMP
objc_msg_lookup_super(struct objc_super *super, SEL sel)
{
	IMP imp;

	if (super->self == nil)
		return (IMP)nil_method;

	imp = objc_sparsearray_get(super->class->dtable, (uint32_t)sel->uid);

	if (imp == NULL)
		return objc_forward_handler(super->self, sel);

	return imp;
}
#endif







|















|




59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

	if (obj == nil)
		return (IMP)nil_method;

	imp = objc_sparsearray_get(obj->isa->dtable, (uint32_t)sel->uid);

	if (imp == NULL)
		return objc_not_found_handler(obj, sel);

	return imp;
}

IMP
objc_msg_lookup_super(struct objc_super *super, SEL sel)
{
	IMP imp;

	if (super->self == nil)
		return (IMP)nil_method;

	imp = objc_sparsearray_get(super->class->dtable, (uint32_t)sel->uid);

	if (imp == NULL)
		return objc_not_found_handler(super->self, sel);

	return imp;
}
#endif